On this page
- Step 1: decide what question you're answering
- Step 2: use realistic requests
- Step 3: open-loop load, not a fixed number of users
- Step 4: sweep the rate and find the knee
- Step 5: control the setup
- Step 6: check quality as well as speed
- Step 7: report it so others can trust it
- The eight most common ways LLM benchmarks mislead
- FAQ
- Go deeper
Most LLM benchmarks you see online can't be compared with each other, and many don't predict production at all. Not because people are dishonest, but because LLM serving performance depends on a lot of things that are easy to leave out. Here's a method that produces numbers you can actually use, with the commands to run it.
#Step 1: decide what question you're answering
Write it down before you start. Examples:
- "What's the most requests per second this GPU can serve with P95 TTFT under 1 s and P95 TPOT under 50 ms, for our chat traffic?"
- "Does FP8 serve more goodput than BF16 for our RAG workload, without losing quality?"
- "Which of vLLM and SGLang serves our agent traffic better on this node?"
A question with a workload and a latency target turns a pile of numbers into an answer. If you haven't picked targets, start with LLM serving metrics explained.
#Step 2: use realistic requests
Performance depends heavily on prompt length, output length and how much prompts share:
- Prompt lengths decide prefill cost and KV memory.
- Output lengths decide how long requests occupy the batch.
- Shared prefixes decide how much prefix caching helps.
Best: sample real (anonymised) requests from your logs, keeping lengths and prefix structure. Next best: a synthetic distribution matching your measured lengths. Worst, but common: fixed 128-token prompts and 128-token outputs, which tell you little about a RAG service with 6K-token prompts.
Also control output length: either cap it at your real distribution with max_tokens, or use a dataset where the model naturally produces realistic lengths. Otherwise one run might generate twice as many tokens as another.
#Describe your traffic first
Before generating load, pull a few numbers from production logs:
| Statistic | Why |
|---|---|
| Prompt length: P50, P90, P99 | Prefill cost and memory |
| Output length: P50, P90, P99 | Decode time and batch occupancy |
| Share of prompt that's a repeated prefix | Prefix cache benefit |
| Peak arrival rate, and how bursty it is | The load range to test |
If you have no production traffic yet, write these down as assumptions and test a range around them.
#Step 3: open-loop load, not a fixed number of users
There are two ways to generate load:
- Closed loop: N simulated users, each sending a request, waiting for the answer, sending the next. If the server slows down, the load drops. This hides overload.
- Open loop: requests arrive at a fixed rate (for example Poisson arrivals at 5 per second) regardless of how fast the server responds. If the server can't keep up, the queue grows and latency shows it. This is how real users behave.
Open loop (real traffic)
Throughput 9 req/s
Mean latency 1,000 ms
Closed loop (20 virtual users)
Throughput 9 req/s (capped by the server)
Mean latency 2,000 ms, steady, whatever the "load" setting
Closed-loop testers send the next request only after the last returns, so a slow server slows the test and latency never explodes. Real users do not wait for each other: open-loop arrivals reveal the queueing cliff. (Single-server M/M/1 for the open loop, 20 virtual users for the closed loop.)
Use open-loop load at a range of arrival rates. Real traffic is often burstier than Poisson; some tools let you add burstiness, which is worth testing if your traffic arrives in waves.
#Step 4: sweep the rate and find the knee
Run at several arrival rates, from light load to beyond capacity. For each rate, record:
- P50, P95 and P99 of TTFT, TPOT (or ITL) and end-to-end latency.
- Throughput: output tokens per second and requests per second.
- Goodput: requests per second that met all targets.
- Engine metrics: batch size, KV cache usage, preemptions, prefix cache hit rate.
Plot latency percentiles against arrival rate. There'll be a knee where TTFT shoots up as queueing starts. Your usable capacity is the highest rate below that knee where goodput still meets your targets.
#The commands
vLLM's benchmark tool runs open-loop load against any OpenAI-compatible server. A sweep might look like this (flags vary by version; check --help):
for rate in 2 4 6 8 10; do
vllm bench serve --model meta-llama/Llama-3.1-8B-Instruct \
--dataset-name random --random-input-len 2048 --random-output-len 256 \
--request-rate $rate --num-prompts 1000 \
--percentile-metrics ttft,tpot,itl,e2el --metric-percentiles 50,95,99 \
--goodput ttft:1000 tpot:50 \
--save-result --result-filename rate-$rate.json
doneSGLang ships an equivalent (python -m sglang.bench_serving), and NVIDIA's GenAI-Perf and other tools do the same job. Whatever you use, use the same tool for every configuration you compare, and replace the random dataset with your real prompts when you can: random tokens have no shared prefixes, so they hide the effect of prefix caching.
#Sanity-check with Little's law
Little's law says the average number of requests in the system equals the arrival rate times the average time each spends there:
At 5 requests per second with an average E2E of 8 seconds, the server should hold about 40 requests at once. Compare that with the engine's "running plus waiting" gauge. If they disagree badly, either the load generator isn't delivering the rate you asked for, or requests are failing or being cut short.
#Step 5: control the setup
Small things move results by 10% or more:
- Warm up before measuring: the first requests include CUDA graph capture, autotuning and cache warm-up.
- Run long enough to reach steady state: at least a few minutes per rate. For stable P99s, collect a few thousand requests; with 200, the P99 is set by the 2 slowest.
- Repeat each configuration several times and report the spread. A 5% gain inside 8% run-to-run noise isn't a gain.
- Pin versions: engine, CUDA, driver, model revision, quantisation.
- Watch the hardware: thermal throttling, power limits, other jobs on the machine.
nvidia-smireports clocks, power and temperature. - Run the client somewhere it can't be the bottleneck, ideally a separate machine, and check its CPU.
- Decide on cache state. Start each run with a cold or a warm prefix cache, deliberately, and say which.
- Change one thing at a time.
#Step 6: check quality as well as speed
Quantisation, speculative settings and some engine flags can change outputs. A speed gain that costs accuracy on your task isn't a gain. Run a task-relevant evaluation alongside performance changes, not just a generic perplexity number (measuring quality).
#Step 7: report it so others can trust it
A good benchmark report fits on one page:
- Question and latency targets.
- Setup: hardware, engine and versions, model and precision, key flags.
- Workload: prompt and output length distributions, prefix sharing, where the data came from.
- Method: open-loop rates, warm-up, duration, repetitions.
- Results: goodput at the target, plus the latency percentile curves.
- Spread: variation across repeated runs.
- Limits: what wasn't tested and where the result might not hold.
#What an example summary looks like
Question: does FP8 weights serve more chat goodput than BF16 on one H100, at P95 TTFT under 1 s and P95 TPOT under 50 ms? Setup: one H100 SXM, engine version and flags listed in the appendix, Llama 3.1 8B. Workload: 2,000 anonymised chat requests; prompts P50 1,100 / P95 4,800 tokens; outputs P50 220 / P95 900 tokens. Method: open-loop Poisson arrivals at 2 to 20 requests per second in steps of 2; 3 minutes warm-up; 1,000 requests per rate; 3 repetitions. Result: goodput rose from X to Y requests per second (spread across runs: Z). Task accuracy on our 300-question evaluation changed from A to B. Limits: single GPU only; bursty traffic not tested.
The letters are placeholders for your own numbers. Anyone reading it can see what was measured, how, and how much to trust it.
#The eight most common ways LLM benchmarks mislead
- Closed-loop load, which hides queueing.
- Averages instead of percentiles.
- Unrealistic prompt and output lengths.
- No latency target, just maximum throughput.
- No warm-up, so the first run pays compilation costs.
- One run, with no measure of noise.
- Different output lengths between configurations being compared.
- Cherry-picked best case: reporting the single best run, or the one batch size where a technique shines.
When you read someone else's benchmark, check it against this list before trusting it. Vendor benchmarks in particular are usually tuned carefully for their own product and run with defaults on everyone else's (vLLM vs TensorRT-LLM).
#FAQ
How long should a benchmark take? For one configuration, a sweep of five to ten rates at a few minutes each, repeated three times: about an hour. Comparing two configurations properly takes an afternoon.
Can I benchmark on a laptop GPU? Yes, for learning the method and for local workloads. Don't extrapolate laptop numbers to data-centre GPUs; the bottlenecks differ.
Should I benchmark with streaming on? Yes, if your users stream. TTFT and ITL only exist with streaming.
#Go deeper
Benchmarking done properly is the full method, free, and the first benchmarking lab takes a real engine from a default configuration to a measured gain. The capstone asks you to produce a report in exactly this format.
benchmarkingperformancevllmsglanginference-engineering
Found this useful?
Send it to someone who is learning the same thing.
Preparing for an interview?
Next: learn it step by step, free
Capacity planning and cost
Turn traffic and latency targets into a GPU count and a monthly bill. A free lesson with step-through diagrams and a quiz.