Design Latency Observability for Time to First Token Across an Inference Fleet
Last updated: November 29, 2026
Quick Overview
Design the metrics, tracing and alerting system that measures time to first token, tokens per second and queueing delay for every model and customer tier, and helps engineers find why latency regressed.
OpenAI
November 29, 20260
0
0 solved
Design the metrics, tracing and alerting system that measures time to first token, tokens per second and queueing delay for every model and customer tier, and helps engineers find why latency regressed.
For OpenAI, latency is product quality: users feel slow first tokens immediately, and regressions can come from routing, batching, prefill length or a bad node. Interviewers want a design that captures the right per-request breakdown, handles high cardinality and supports fast diagnosis.
What the Interviewer Expects
- Define the latency decomposition: gateway, queue, prefill, first decode step, streaming
- Instrument with distributed tracing and per-stage timestamps on every request
- Aggregate into histograms with controlled label cardinality
- Support slicing by model, region, tier, prompt length bucket and replica
- Alert on SLO burn rate rather than raw thresholds
- Keep raw request-level events for drill-down
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
- Why is averaging latency across replicas misleading, and what do you aggregate instead?
- How do you attribute a p99 regression to prompt length mix versus a real slowdown?
- How do you handle per-customer latency dashboards for enterprise accounts?
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
- Metrics: TTFT, inter-token latency, total latency, queue wait, prefill time, tokens in and out, errors.
- Dimensions: model, region, cluster, replica, tier, endpoint, streaming or not, prompt length...
High-Level Design
- Instrumentation: each component stamps the request:
t_received,t_routed,t_enqueued,t_prefill_start,t_first_token,t_last_token; OpenTelemetry spans with sampling. - **Metrics pip...