Skip to main content

Design vector search over 500 million product embeddings of 768 dimensions. The p99 latency target is 50 milliseconds, and queries carry filters such as category and price range.

System design · Pro 3

Short answer

Clarify recall target, query rate, update rate and filters. The raw vectors need about 1.5 TB, so exact search is not possible. Use approximate nearest neighbour indexes on shards, compress vectors with quantization, rerank the top results with full vectors, apply filters inside the search, and measure recall against exact search on a sample.

Deeper answer

Clarify the recall target, query rate, update rate and filter selectivity. Then estimate size. 500 million vectors of 768 32-bit floats take about 1.5 TB before any index, so memory is the main cost.

Design: split the data into shards, each with replicas. A query goes to all shards in parallel and the results are merged. Inside a shard, use an approximate nearest neighbour index. A graph index gives high recall and low latency but uses a lot of memory. A clustered index with product quantization stores short codes, which cuts memory many times at some loss of recall. Then rerank the top few hundred results with full vectors kept on disk.

Filters are the hard part. Filtering after the search can return too few results when the filter is selective. Filtering before can make the index useless. Use filter-aware search, or partition by a common field such as category.

Evaluate recall at k against exact search on a sample of queries. Trade-offs: recall, latency and memory pull against each other. At scale, tail latency from the slowest shard, index rebuild time and selective filters break first.

What a strong answer covers

Answer it out loud in the mock interview about 3 min

Follow-ups to expect

Common mistakes

Learn it

Vector search

Practice System design questions

More on this topic

Today's AI turns are used

Lessons, roadmaps, videos, practice cards and the code playground stay free with your account, with no limit.