Skip to content
Inference Academy

How to benchmark an LLM server without fooling yourself

A practical method for benchmarking vLLM, SGLang or any LLM server: realistic prompts, open-loop arrival rates instead of fixed users, warm-up, percentiles, goodput against targets, repeated runs, and a report format others can trust. With the commands for vLLM's and SGLang's benchmark tools, a sanity check using Little's law, how many requests you need for a stable P99, an example report, and the eight most common ways LLM benchmarks mislead.

Key takeaways

  • Start with a written question that names a workload and latency targets.
  • Use realistic prompt and output lengths and prefix sharing, ideally sampled from real traffic.
  • Use open-loop load at several arrival rates; closed-loop users hide overload.
  • Warm up, run long enough for stable percentiles, repeat runs, pin versions and change one thing at a time.
  • Report goodput at your targets with latency percentiles, spread across runs and a quality check.

By

7 min read

Share
On this page

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 versus closed-loop load: why your benchmark may lie
Interactive

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):

bash
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
done

SGLang 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:

concurrent requests=arrival rate×average E2E latency\text{concurrent requests} = \text{arrival rate} \times \text{average E2E latency}

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-smi reports 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:

  1. Question and latency targets.
  2. Setup: hardware, engine and versions, model and precision, key flags.
  3. Workload: prompt and output length distributions, prefix sharing, where the data came from.
  4. Method: open-loop rates, warm-up, duration, repetitions.
  5. Results: goodput at the target, plus the latency percentile curves.
  6. Spread: variation across repeated runs.
  7. 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

  1. Closed-loop load, which hides queueing.
  2. Averages instead of percentiles.
  3. Unrealistic prompt and output lengths.
  4. No latency target, just maximum throughput.
  5. No warm-up, so the first run pays compilation costs.
  6. One run, with no measure of noise.
  7. Different output lengths between configurations being compared.
  8. 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.

Share this article

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.

Get new articles by email

One short email when a new guide is out. Unsubscribe any time.