Zenaique

End to end latency: fill in the queue, prefill and decode components.

Fill in blank·Easy·4.0 · 0·~1 min·Asked atGraphcoreLtimindtreePalantir·Relevant atOpenAI
Attempt it
End to end latency for a single LLM completion producing N_out output tokens decomposes as: queue_time + + (N_out - 1) * . The first non-queue term is dominated by compute and is what users perceive as TTFT. The second term grows linearly with output length and is dominated by memory bandwidth. For long completions the second term typically the first.
TL;DR

End-to-end latency decomposes into queue_time + TTFT + (N_out - 1) * TPOT, where TTFT is compute-bound prefill and TPOT is bandwidth-bound decode.

Memory aid
Sign in to see the mnemonic that makes this stick.
Easy to grasp

Picture sending a package through a busy mailroom. First it sits in line behind other packages: that is queue time. Then a clerk has to read the whole address (the entire prompt) before anything can move: that is TTFT, paid once. After that, the clerk hand-writes one stamp at a time onto the box, again and again, until it is fully labeled. Each stamp is the same small wait, but you pay it once per stamp. If the package needs hundreds of stamps, that second pile of waits ends up much bigger than the one-time address-reading. End-to-end latency is the sum of all three pieces.

Concept explanation~2 min read

Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.

End-to-end latency is the most-watched, most-misunderstood metric in LLM serving. Engineers new to the space often quote a single 'response time' number, then get surprised when their chat UI feels broken at p95 even though the average looks fine. The fix is to stop treating latency as one number and start treating it as a sum of three structurally different terms.

This deep dive walks through the canonical decomposition queue + TTFT + (N_out - 1) * TPOT, why each term has a different cost driver, what production levers move each one, and why separate SLOs for TTFT and total completion time are non-negotiable on any serious chat product.

The three-term decomposition in detail

A single LLM request producing N_out output tokens spends time in exactly three places.

  • Queue time: the interval between request arrival at the server and the start of compute. On an idle server this is near zero. Under load, it is the dominant component of p95 and p99 latency because requests pile up behind running batches.
  • TTFT: the wall-clock cost to read the entire input prompt, run one parallel prefill forward pass, and emit the first output token. TTFT scales with input length T_in but not with output length. It is what a streaming client observes as the gap before the first character appears.
  • (N_out - 1) * TPOT: the autoregressive decode loop. Each of the remaining output tokens requires its own forward pass, and each pass costs roughly TPOT (a few tens of milliseconds on modern hardware). This term scales linearly with N_out.

The breakeven math

For TTFT around 300ms and TPOT around 25ms, decode equals prefill at N_out around 13. Past that, decode dominates. Most real-world completions are 50-1000 tokens, putting them firmly in the decode-dominated regime.

Why prefill is compute-bound and decode is bandwidth-bound
Production levers for each term
Why SLOs split and how production stacks expose this
Sign in to unlock the full deep dive.

Situations where this technique stops working.

Sign in to see when this approach fails.

2–4 min · Everything important, quickly.

Sign in to see the quick scan of the deep dive.

Real products, models, and research that use this idea.

  • vLLM v1's benchmark scripts report p50/p95/p99 for both TTFT and inter-token latency (effective TPOT) separately, plus queue depth.
  • Anthropic Claude Sonnet 4.6 dashboards alert on TTFT and total completion time as separate SLOs; long-context chat targets p95 TTFT under one second.
Sign in to see more production examples.

What an interviewer would ask next. Try answering before peeking at the approach.

QIf TTFT = 200ms and TPOT = 30ms, what is the breakeven output length where decode equals prefill?
A

Solve (N_out - 1) * 30ms = 200ms, giving N_out about 8. Past 8 output tokens, decode dominates. Most real completions are 50-500 tokens, so decode is the main cost driver almost always.

2 more follow-ups an interviewer would ask next. Sign in to reveal them.

Red flags & common mistakes

The phrases that signal junior thinking. Click to expand.

Most common mistake

Lumping TTFT and per-token decode into one latency number. They move on different axes and need separate SLOs because prefill is compute-bound while decode is bandwidth-bound.

Sign in to see all red flags and common mistakes.

60 second bullets to scan on the way to the call.

  • The three-term decomposition: queue, TTFT, (N_out - 1) * TPOT

  • Why prefill is compute-bound and decode is bandwidth-bound

Sign in to unlock the revision sheet.

Primary sources. Browse if you want the original framing.

Similar questions

Same topic, related formats. Practice these next.

4 curated
Next question
What is the KV cache in transformer inference?
Flashcard·Easy