"Is it fast?" has at least five different answers for an LLM service, and optimising the wrong one is the most common mistake in inference work. This lesson defines the metrics precisely (time to first token, time per output token, inter-token latency, end-to-end latency, throughput and goodput), shows how to compute them from timestamps, explains why percentiles matter more than averages, and maps each kind of bottleneck to the metric it damages.
- Define TTFT, TPOT, ITL, end-to-end latency, throughput and goodput precisely
- Compute those metrics from request and token timestamps
- Explain the throughput versus latency trade-off as concurrency rises
- Use percentiles and say where measurements should be taken
- Map queueing, prefill, decode, memory and CPU bottlenecks to the metrics they hurt
The latency metrics
| Metric | Definition | Driven mostly by |
|---|---|---|
| TTFT (time to first token) | Request sent to first output token received | Queue wait + prefill |
| TPOT (time per output token) | (end-to-end - TTFT) / (output tokens - 1), per request | Decode step time, batch size |
| ITL (inter-token latency) | Each gap between consecutive streamed tokens | Decode steps, interference from prefill |
| E2E latency | Request sent to last token received | All of the above x output length |
TPOT and ITL are close relatives. TPOT is one average number per request; ITL is the whole distribution of gaps, which exposes stalls: a stream that usually ticks every 20 ms but freezes for 400 ms while the engine prefills someone else's long prompt has a fine average TPOT and a terrible ITL tail. Users read that freeze as the service hanging.
def request_metrics(t_sent, token_times):
"""t_sent: request start; token_times: arrival time of each streamed token."""
ttft = token_times[0] - t_sent
e2e = token_times[-1] - t_sent
n = len(token_times)
tpot = (e2e - ttft) / (n - 1) if n > 1 else 0.0
itl = [b - a for a, b in zip(token_times, token_times[1:])]
return {"ttft": ttft, "tpot": tpot, "e2e": e2e, "itl": itl}Throughput, goodput and the trade-off
Throughput is work per unit time: output tokens per second (the usual headline), total tokens per second, or requests per second. Per GPU is the number that maps to cost. Goodput is throughput that meets your latency targets, for example requests per second completed with TTFT under 500 ms and TPOT under 50 ms. A configuration that doubles throughput by blowing through the latency target has improved nothing users care about.
As you raise concurrency, batches get bigger: throughput climbs because each weight read serves more requests, but every request's decode step gets slower and queues start forming, so TTFT and TPOT rise. Plotted as throughput against latency, every engine and configuration traces a curve, and the right operating point is the highest throughput that still meets the latency SLO.
Never report a throughput number without the concurrency or request rate, the input and output lengths, and the latency percentiles it was measured at. Without those, the number is not comparable to anything.
Percentiles and where to measure
- Report p50, p90 and p99, not the mean. LLM latency distributions have long tails from queueing, long prompts and preemption.
- Client-side measurement includes network and the gateway; it is what users feel and what SLOs should use.
- Server-side engine metrics (histograms for TTFT and inter-token latency) isolate the engine, which is what you tune.
- A large gap between the two points at the network, a gateway, or the client's own processing.
- Measure under the real mix of input and output lengths; a benchmark of 128-token prompts says little about a RAG app with 6,000-token prompts.
A worked example: reading one benchmark run
Suppose a benchmark at concurrency 16 reports p50 TTFT of 180 ms, p99 TTFT of 2.1 s, p50 TPOT of 24 ms and p99 TPOT of 31 ms, with 2,900 output tokens per second. The decode numbers are tight, so steady-state generation is healthy: at 24 ms per token each user sees roughly 40 tokens per second, faster than anyone reads. The trouble is the TTFT tail. A p99 more than ten times the median means a minority of requests waited a long time before starting.
There are two usual explanations, and the other metrics tell them apart. If waiting requests climbed during the run, capacity ran short at moments of burst and requests queued: add replicas, or admit fewer requests per replica and scale out earlier. If the slow requests were the ones with the longest prompts, prefill itself is the cost: prefix caching, chunked prefill, a faster GPU for prefill, or eventually disaggregated prefill are the levers. Look at TTFT broken down by input length before choosing.
Now rerun at concurrency 32. If throughput rises to 3,600 tokens per second but p99 TPOT jumps to 58 ms, you have crossed a 50 ms streaming target: the extra throughput is not goodput. The operating point for this configuration sits somewhere between 16 and 32 concurrent requests per replica, and that number, not the peak throughput, is what you feed into capacity planning and autoscaling thresholds.
Bottlenecks and their fingerprints
| Bottleneck | Metric it hurts | Fingerprint |
|---|---|---|
| Queueing (not enough capacity) | TTFT | Waiting requests grow; TTFT rises while TPOT is steady |
| Prefill compute | TTFT, ITL tail | TTFT tracks prompt length; stalls in other streams during long prefills |
| Decode bandwidth / large batch | TPOT | TPOT rises with concurrency; GPU memory traffic saturated |
| KV-cache memory | TTFT, tail latency | Cache usage near full; preemptions |
| CPU (tokenizer, scheduler, HTTP) | Everything | CPU pegged, GPU underused |
| Network or gateway | Client-side only | Server metrics fine, client metrics poor |
With these fingerprints you can read most incidents from a dashboard of four panels: TTFT and TPOT percentiles, running versus waiting requests, KV-cache usage, and throughput. The observability lesson builds exactly that.