How do you measure and optimize TTFT, TPOT, and goodput under production SLA constraints?
Written by the mlprep team · Updated
A teammate benchmarks two LLM serving configurations and reports that Config B achieves 2× higher tokens/second than Config A, recommending we ship Config B immediately. Why might that be a mistake? Walk me through the metrics that actually matter for production LLM inference.
Why raw tokens/sec is a vanity metric#
You can almost always double aggregate throughput (tokens/sec) simply by letting requests queue longer and pushing batch size to the ceiling. The GPU looks 100% utilized, while real users stare at a blank screen for 6 seconds and watch tokens trickle out slower than reading speed.
Production LLM serving is a latency-constrained optimization problem. You must measure four core metrics together:
- TTFT (Time to First Token): Time from request arrival until the first output token streams back. Dominated by queueing delay + prefill compute. Critical for perceived responsiveness (typical interactive SLA: P95 < 500ms–1.5s).
- TPOT (Time Per Output Token) / ITL (Inter-Token Latency):
TPOT= average time per generated token across a response ((E2E - TTFT) / (output_tokens - 1)).ITL= latency between each consecutive pair of tokens. P99 ITL catches mid-stream freezes (e.g., when a huge prefill stalls a decode batch) that average TPOT hides!- Typical interactive SLA: < 30–50ms/token (~20–33 tokens/sec, faster than human reading speed).
- E2E Latency: Total time until the final token (
TTFT + TPOT × output_tokens). Matters most for non-streaming / agentic tool calls where downstream code blocks until the full JSON response finishes. - Goodput (the north-star metric): Maximum requests/sec (or output tokens/sec) that satisfy all SLA targets simultaneously (e.g., P95 TTFT < 1s AND P95 ITL < 40ms).
Throughput: total tokens/sec regardless of user pain
Goodput: requests/sec meeting BOTH TTFT and TPOT/ITL SLAs
Config B's 2× raw throughput is worthless if it violates TTFT or ITL SLAs and yields lower goodput than Config A.
Suppose your interactive chat service is hitting its TPOT SLA comfortably (22ms/token), but P95 TTFT has spiked to 3.5 seconds during peak traffic. How do you diagnose the root cause and fix it systematically?
Step 1: Decompose TTFT into Queue Time vs. Prefill Time#
Instrument the serving engine to log t_arrival, t_scheduled, and t_first_token:
- High Queue Time (
t_scheduled - t_arrival): Requests are waiting for KV cache blocks or scheduler slots.- Fixes: Enable/tune prefix caching (frees prefill slots faster), quantize KV cache to FP8 (increases concurrent slots), add replicas (scale DP), or tune admission control / chunked prefill token budget (
max_num_batched_tokens) so waiting prefills aren't starved by ongoing decode.
- Fixes: Enable/tune prefix caching (frees prefill slots faster), quantize KV cache to FP8 (increases concurrent slots), add replicas (scale DP), or tune admission control / chunked prefill token budget (
- High Prefill Time (
t_first_token - t_scheduled): Prefill itself is slow because prompts are huge or compute is saturated.- Fixes: Enable automatic prefix caching + prefix-aware routing (often cuts prefill by 50%–90% on multi-turn/agentic traffic), switch from W4A16 to FP8 on Hopper+ GPUs (unlocks 2× prefill FLOPs), increase chunked prefill budget slightly (trading a few ms of TPOT headroom for faster TTFT), or move to prefill-decode disaggregation if long-context prompts are saturating decode GPUs.
Step 2: Benchmark realistically before shipping#
Synthetic benchmarks with fixed 512-in / 128-out lengths and uniform arrival rates hide real failure modes. Always replay:
- Real input/output length distributions (long-tail prompts drive TTFT spikes).
- Bursty Poisson / production arrival traces (queues build nonlinearly near 80% utilization).
- Actual prefix-sharing patterns (multi-turn conversations).
Senior/staff considerations#
- Plot the Pareto frontier: Evaluate every serving change on a
Goodput (QPS/GPU) vs. Latency SLAcurve rather than a single operating point. This directly translates into cost per million tokens at target SLA. - Separate interactive vs. batch tiers: Never mix latency-sensitive interactive users with offline batch jobs on the same queue without strict priority preemption — offline jobs can absorb high TTFT and run at massive batch sizes for 3× lower cost.
Interview red flags#
- Optimizing only average throughput or mean latency while ignoring P95/P99 tail latency and ITL jitter.
- Conflating TPOT (smoothed per-request average) with ITL (per-token stutter) — a 500ms freeze disappears in TPOT over a 200-token response but feels broken to users.
- Benchmarking at constant concurrency without modeling queueing delay under realistic arrival rates.
The key takeaway unlocks after you reveal an expert answer.
Key Takeaway
Raw tokens/sec is misleading because large batches trade away user latency. Production inference should be optimized for goodput — maximum QPS per GPU meeting both TTFT (queue + prefill) and TPOT/ITL (decode smoothness) SLAs simultaneously — measured on realistic length distributions and bursty traffic traces.
Follow-up Questions to Test Yourself
Interviewers often pivot here once you cover the core concept.
- Why can a request have an acceptable TPOT of 25ms while still feeling laggy to a streaming user?
- How do your optimization priorities differ between a streaming chat UI and a non-streaming agentic JSON tool-calling pipeline?
- How does KV cache utilization approaching 95% affect P99 TTFT even when GPU compute utilization looks moderate?
How confident do you feel explaining this?
Track your understanding or flag it to revisit before your next loop.
Related Questions
Why do prefill and decode have opposite hardware bottlenecks, and how does disaggregated serving help?
How does continuous batching work and why does static batching waste GPU utilization?
How does prefix caching (RadixAttention) speed up multi-turn and agentic LLM workloads?
How do you serve ML models at low latency and high throughput?