Measuring Latency and Cost Honestly
You'll be able to:
You can define time-to-first-token, inter-token latency, tokens per second and goodput, explain why averages and single-request benchmarks mislead, compute cost per million tokens from an hourly machine price and a measured throughput, and list the ways a vendor benchmark can be technically true and still irrelevant to your production load.
Define the metric before you run the benchmark
Inference benchmarks are easy to make look good and hard to make honest. The reason is that "fast" hides four different quantities, and a system can be excellent at one while being unusable on another. Before any run, write down which of these you are reporting:
- Time to first token (TTFT) — from request arrival to the first streamed token. Dominated by queueing and prefill; it is what a user experiences as "is it thinking?".
- Inter-token latency (ITL), or its inverse, per-user tokens per second — how fast the answer streams once started. Dominated by the decode step time at the current batch size.
- End-to-end latency — TTFT plus ITL × output length. The only thing that matters for non-streaming API calls.
- Throughput — total tokens per second across all users, which is what sets cost. Report input and output tokens separately; they cost different amounts of work.
A fifth, goodput, is throughput counted only for requests that met a latency target. It is the honest number for capacity planning, because a server that produces 10,000 tokens/s while every user waits 20 seconds for the first one is not serving anyone.
Why averages lie
Gil Tene's talk "How NOT to Measure Latency" is required viewing. Three of his points matter most here. First, the mean of a latency distribution describes nobody; users experience the tail, and a session of twenty requests sees at least one response at or beyond the p95 about two times in three (1 − 0.95²⁰ ≈ 64%). Second, coordinated omission: if your load generator waits for each response before sending the next request, a slow period causes it to send fewer requests, and the slow period is under-sampled in your data. The fix is an open-loop generator that fires requests on a schedule regardless of responses (a Poisson arrival process at a chosen rate), and a closed-loop generator only when your real clients genuinely behave that way. Third, percentiles must come from the full set of recorded samples, not from averaging percentiles across intervals, which is meaningless.
For LLM serving, add a fourth: the distribution of prompt and output lengths shapes everything. A benchmark with 128-token prompts and 128-token outputs says nothing about your 3,000-token RAG prompts and 50-token answers. Databricks' "LLM Inference Performance Engineering: Best Practices" shows the same hardware producing very different numbers as input/output shapes and concurrency change, and gives the practitioner's checklist for stating them.
Turning tokens per second into money
Cost per token is a derived number and the derivation should be shown. A numbered procedure:
- Measure sustained aggregate throughput at the concurrency and latency target you actually accept — say 2,400 output tokens/s at 32 concurrent users with p99 TTFT under 1.5 s.
- Convert to tokens per hour: 2,400 × 3,600 = 8.64 million output tokens per hour.
- Divide the machine's hourly price by that. If the machine costs 4.00 per hour in your currency, the cost is 4.00 ÷ 8.64 ≈ 0.46 per million output tokens at full utilisation.
- Correct for real utilisation. Traffic has peaks and valleys; if the server averages 40% of peak over a day, the effective cost is 0.46 ÷ 0.4 ≈ 1.16 per million. Autoscaling narrows the gap but adds cold-start latency.
- Add input tokens with their own throughput measurement, and overheads: idle replicas for failover, the engineer-hours of running it, and egress.
Compare that number to an API price only after step 4. Most "self-hosting is 10× cheaper" claims stop at step 3.
Vendor benchmarks: true but irrelevant
MLPerf Inference, run by MLCommons, is the most rigorous public benchmark: fixed models, fixed datasets, accuracy constraints, audited submissions, and separate "server" (latency-constrained) and "offline" (max throughput) scenarios. Read the rules before the results and you learn what a careful benchmark must specify. Even so, its numbers come from vendors' best-tuned configurations on the benchmark's shapes. Ways a published figure can be accurate and still useless to you:
- Measured at a batch size or sequence shape you will never see.
- Offline scenario quoted as if it were a latency-bound one.
- Different precision (FP8) than you are willing to run.
- Warm KV cache from repeated identical prompts (prefix caching inflates throughput enormously on synthetic loads).
- Short runs that never hit thermal or memory-fragmentation steady state.
Your own benchmark should state model, precision, server version, hardware, prompt and output length distributions, concurrency, arrival process, warm-up, duration, and the percentiles reported — every time, in the results table.
What is still unsettled
Reasoning models that generate long hidden chains of thought make "output tokens" an ambiguous quantity for pricing, and goodput definitions for agentic, multi-call workloads are not standardised. Energy per token is the metric many organisations will soon be asked to report and few currently measure.
What to remember
- Name the metric: TTFT, inter-token latency, end-to-end latency, throughput (input and output separately), goodput.
- Report percentiles from full samples, use open-loop load to avoid coordinated omission, and match the workload's length distribution.
- Cost per million tokens = hourly price ÷ (sustained tokens/s × 3,600), then divided by real utilisation; stopping before utilisation flatters self-hosting.
- A vendor number is only comparable when model, precision, shapes, concurrency, scenario and caching state are the same as yours.
Curated Materials
1.7hThe deep work happens here — the lesson is your briefing.
Live on aiqbench
This lesson's subject on the rest of the site, today.
In the news, last 30 days
- GPU decoder keeps pace with a superconducting qubit clock on a continuous stream, with NVIDIA NVQLink interconnectAlice & Bob ·
- DeepSeek Opens Source Production-Level Ascend Inference Code36Kr ·
- NVIDIA and Cerebras Partner to Accelerate AI Agent Inference with Two-Stage Compute Architecture36Kr ·
Test your knowledge
5 questions in 100 seconds, on a page of its own. Read everything above first.
Test your knowledge →Module Mission
30–40 minDesign a benchmark plan for a hypothetical customer-support assistant: 600-token prompts, 150-token answers, 20 concurrent users at peak. Write it as a one-page document covering the exact metrics you will report (with definitions), the load pattern (open-loop versus closed-loop, and why), the warm-up and run duration, what percentiles you will quote and why p99 rather than mean, how you will turn tokens/s into cost per million tokens, and the three mistakes from Gil Tene's talk you are explicitly guarding against.
Loading your work…