Design Low-Latency Gemini Serving With Continuous Batching on TPUs
Last updated: November 29, 2026
Quick Overview
Design the serving system for a large chat model behind a consumer app, meeting time-to-first-token and tokens-per-second targets while maximizing accelerator utilization. Cover batching, KV cache management and model parallelism.
0
0
0 solved
Design the serving system for a large chat model behind a consumer app, meeting time-to-first-token and tokens-per-second targets while maximizing accelerator utilization. Cover batching, KV cache management and model parallelism.
LLM serving efficiency drives the cost of every generative feature at Google, so infrastructure-leaning ML interviews dig into prefill versus decode, memory for the KV cache and sharding across TPU chips. Interviewers want concrete numbers and clear trade-offs between latency and throughput.
What the Interviewer Expects
- Separate prefill and decode phases and their different bottlenecks
- Use continuous batching and paged KV cache memory
- Choose tensor and pipeline parallelism to fit the model
- Set SLOs for time to first token and inter-token latency
- Discuss prefix caching, quantization and speculative decoding
Key Topics to Cover
How to Approach This
- Start by mapping the business objective to a concrete ML objective and metric.
- Cover the full pipeline: data collection, feature engineering, model selection, training, serving.
- Discuss online vs offline evaluation. Plan an A/B test to validate real-world impact.
- Address the serving latency budget and whether batch or real-time inference is needed.
- Think about the data flywheel: how user feedback improves the model over time.
Possible Follow-up Questions
- How big is the KV cache for a 32k-token context and how does that limit batch size?
- When would you disaggregate prefill and decode onto different pools?
- How do you prevent one very long prompt from hurting everyone's latency?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice ML System Design ProblemsSample Answer
Requirements
Targets: time to first token under 500 ms at p50, inter-token latency under 30 ms, at a peak of hundreds of thousands of concurrent conversations. Model: tens of billions of parameters, context up to ...
High-Level Design
- Frontend: authenticates, applies safety pre-checks, routes to a region and model replica.
- Scheduler per replica: continuous batching, admitting new requests every decode step.
- **Model...