Design Embedding Retrieval Serving With an Approximate Nearest Neighbor Index
Last updated: November 29, 2026
Quick Overview
Design the serving system that retrieves the top 1,000 candidate Reels for a user from a corpus of billions using user and item embeddings, within a 30 ms budget, while new videos enter the index continuously.
Meta
November 29, 20260
0
0 solved
Design the serving system that retrieves the top 1,000 candidate Reels for a user from a corpus of billions using user and item embeddings, within a 30 ms budget, while new videos enter the index continuously.
Meta's recommendation stack relies on embedding-based retrieval, and its open source vector search library shaped the field. Infra-focused ML interviews check ANN index choices, sharding, freshness, and how retrieval quality is measured.
What the Interviewer Expects
- Explain why exact nearest neighbor is infeasible
- Choose an ANN index such as IVF with product quantization or HNSW
- Shard and replicate the index for latency
- Add fresh items without full rebuilds
- Measure recall against exact search
Key Topics to Cover
How to Approach This
- Start by clarifying functional and non-functional requirements with the interviewer.
- Estimate the scale: QPS, storage, bandwidth. This drives your design decisions.
- Draw a high-level architecture first, then deep dive into 1-2 critical components.
- Discuss trade-offs explicitly (e.g., consistency vs availability, SQL vs NoSQL).
- Address failure scenarios, monitoring, and how the system handles 10x traffic spikes.
Possible Follow-up Questions
- How does the index handle a model refresh that changes all embeddings?
- How would you filter by language or age rating during retrieval?
- What recall at 1,000 would you target and why?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice System Design ProblemsSample Answer
Requirements
Functional: given a user embedding, return top ~1,000 items by inner product, with filters (region, language, integrity); new items retrievable within minutes.
Non-functional: 30 ms p99; tens...
High-Level Design
- A user tower runs online (or reads a cached user embedding) to produce a query vector.
- An ANN service holds the item index, sharded across hosts; a broker scatters the query, each shard re...