Skip to main content

Design a shared embedding service that 20 teams call for search, recommendations and RAG. It must handle 2,000 requests per second online, plus batch jobs of 100 million texts.

System design · Pro 1

Short answer

Clarify the clients, input types, latency targets and how often the model will change. Then: one API with separate online and batch paths, dynamic batching on GPUs, a cache keyed by text hash and model version, quotas per team, strict versioning because vectors from different models cannot be mixed, a re-embedding plan, and quality checks on retrieval tasks.

Deeper answer

Clarify who calls it and why. Search queries need low latency, about 50 milliseconds. Indexing 100 million documents needs throughput, not speed.

Design: a stateless API in front of model servers on GPUs. The online path uses dynamic batching, which collects requests for a few milliseconds to fill a batch. The batch path reads from a queue or object storage and runs on separate capacity, so a large job cannot slow down live traffic. A cache keyed by the hash of the text and the model version removes repeated work. Each team has a quota and usage is metered.

The hardest part is versioning. Vectors from two models are not comparable, so every vector carries its model version. A model upgrade means all stored vectors must be embedded again and each index rebuilt, then switched together with the query side.

Evaluate candidate models on each team's own retrieval task, with recall at k, not only on public benchmarks. Trade-offs: larger vectors and models improve quality but raise storage and latency. At scale, noisy neighbours, long inputs that are silently truncated, and migrations between model versions break first.

What a strong answer covers

Answer it out loud in the mock interview about 2.5 min

Follow-ups to expect

Common mistakes

Learn it

Embeddings

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.