End-to-end latency is a sum of six terms, and knowing which one moved is most of debugging a regression.
The budget
| Term | Typical | Driven by |
|---|---|---|
| (TLS + RTT + LB) | 5–50 ms | geography, connection reuse |
| 0 → ∞ | load vs capacity | |
| prompt length, Prefix Caching | ||
| 5–30 ms | batch, KV bytes, bandwidth | |
| µs–ms/token | incremental decode, stop-string matching | |
| ms | SSE chunking, proxy buffering, Nagle |
Output length dominates: at 20 ms TPOT, 500 tokens = 10 s of decode, next to which a 50 ms TTFT is noise. Optimize TTFT for chat, TPOT for long generations, throughput for batch jobs.
Where the tail comes from
- is the only unbounded term. In an M/M/1-ish regime waiting time scales as : at 90% utilization the queue is 9× the service time; at 95%, 19×. Tail latency is a utilization decision.
- Head-of-line blocking: one 100K-token prefill stalls every decode in the batch for its full duration unless you use chunked prefill.
- Preemption: an evicted sequence pays a recompute or swap on resume.
- A request that touches independent components each slow with probability is fast with probability : tail amplifies with fan-out.
Report P50 / P95 / P99 for TTFT and TPOT separately, and normalize per output token. A single “average latency” number hides both the queue and the prompt-length mix.
Attributing a regression
- TTFT up, TPOT flat → queue, admission, prefill, or cache hit-rate drop. Check prefix-cache hit rate and prompt-length distribution first; a shifted input mix looks exactly like a code regression.
- TPOT up, TTFT flat → larger batches, longer average context (KV traffic ), or bandwidth contention.
- Both up → fewer healthy replicas, thermal/power throttling, or a slower kernel.
- P50 flat, P99 up → queueing or preemption, not kernels.
- Server-side flat, client-side up → network, proxy buffering, or the client’s own detokenize/render loop.
Instrument per-request: arrival, admission, first forward, first token emitted, last token, plus prompt/output lengths, batch size at admission, and preemption count. Without those you cannot separate terms 1 and 2.
Quick model check
Compare measured TPOT against from Inference Back-of-Envelope. A gap of 2× or more that is not explained by batch or context means overhead, launches, collectives, or host-side scheduling, not bandwidth.
Rule of thumb
Latency is a distribution, not a number, and the tail lives almost entirely in the queue. If you want a good P99, run below 70–80% utilization or bound the queue explicitly.