Search Microservice: Product Discovery at Million-Item Scale
A typo-tolerant search API for one million products and roughly 29,000 brands, designed for a small cloud VM.
The problem
A product search needs to handle misspelled queries and concurrent traffic without requiring a large server. The project targets a two-CPU, 12 GB RAM environment and keeps the database out of the request-time search path.
How it works
PostgreSQL holds the source records while OpenSearch provides a rebuildable search index. A FastAPI service queries the product and brand indices concurrently and applies field boosts to favor relevant titles.
An in-process LRU cache and a short-lived Redis cache absorb repeated queries. Nginx applies a per-IP rate limit before traffic reaches the API. Docker Compose and k6 provide a reproducible way to run and load-test the stack.
Results and limits
In the published, resource-limited benchmarks, warm repeat queries reached about 180 requests per second at 3.2 ms P95. Unseen typo queries reached 179 requests per second at 13 ms P95. A separate unthrottled ceiling test reached 1,046 requests per second with much higher latency; it is not the normal serving target.
The repository explains the benchmark setup and an adversarial typo test that exposed failures hidden by warm-cache runs. The public clone does not include the multi-gigabyte product dataset.