Topic 5 of 5 · 5 min read
Load testing LLM endpoints realistically
Goal: Read a load-test result and find the saturation point and the limit that caused it.
A load test tells you where an LLM endpoint saturates and which limit caused it, but only if the test looks like production traffic. A test with short prompts and no streaming will report a capacity you will never see.
Check yourself · 1 of 3
Why should a load test of an LLM endpoint use a realistic mix of prompt lengths?
Why it matters
LLM calls are slow and uneven. One request may return in half a second and another in forty. Capacity depends on prompt length, output length and how many calls run at the same time. Latency under load also has two parts users feel: time to first token (how long until text starts) and the speed of the stream after that.
How to do it
- Build a realistic mix. Sample real prompts, or generate ones with the same input and output length distribution, including the long tail. Do not repeat one prompt, because caching will flatter the result.
- Stream. Measure time to first token and tokens per second separately from total time.
- Ramp the concurrency. Step up, for example 1, 2, 4, 8, 16, 32 concurrent users, holding each step for a few minutes. A single big jump hides where it bends.
- Record per step: requests and tokens per second, p50 and p95 time to first token, error rate and the status codes returned.
- Find the saturation point. It is the step where throughput stops rising while latency and errors climb. Then look at the cause: 429s mean a rate limit, timeouts or rising queue time mean the server is out of capacity, and errors from your own gateway mean your own limits.
- Control cost. Tests against a paid model spend real money. Use a short test window, a cheaper model with a similar profile for early runs, a budget cap on the key and a fake backend for testing your own gateway. Tools such as LLMPerf can drive the load.
- Check the test is not the bottleneck. If the load generator is CPU bound, you are measuring the generator.
Before and after
Weak result: "The endpoint handled 200 requests a minute with an average latency of 3 seconds." It used one 50-token prompt and no streaming.
Better result: "With the production mix (median 1,500 input and 250 output tokens), throughput rose to 24 concurrent users, then flattened. Above that, p95 time to first token went from 1.2 s to 9 s and 429s appeared, so the input tokens per minute limit binds at about 24 users."
What goes wrong
- Averages only. The mean looks fine while the 95th percentile breaks the product.
- A cached prompt. Repeating one prompt measures the cache.
- Testing production quota. A load test on the live key can cause 429s for real users. Use a separate key or off-hours.
- Stopping at the first error. The shape of the failure (429s, then timeouts) tells you which fix to apply.
Examples
Reading a ramp
users req/s ttft_p50 ttft_p95 errors
4 1.8 0.6 s 0.9 s 0
8 3.5 0.6 s 1.1 s 0
16 6.4 0.8 s 1.9 s 0
24 7.9 1.2 s 3.4 s 0
32 8.0 4.8 s 11 s 9% (429)
Throughput flattens near 8 requests a second at 24 users, and at 32 users 429s appear. A 429 points to a provider rate limit, not slow servers. Work out which token limit 8 requests a second at your prompt size reaches.
Why the prompt mix matters
A team tests with a 100-token prompt and finds the endpoint handles 40 requests a second. Production prompts average 3,000 tokens because of retrieved documents. At that size the input-token limit allows far fewer requests a second, so the launch fails on day one although the test passed.
Key points
- Use a realistic mix of prompt and output lengths, including the long tail, and never repeat a single prompt.
- Measure time to first token and tokens per second separately by streaming.
- Ramp concurrency in steps and record throughput, p95 latency and error codes for each step.
- Saturation is the step where throughput stops rising while latency and errors climb; the status codes show which limit caused it.
- Load tests spend real money and can use real quota, so cap the budget and use a separate key.
Common mistakes
- Testing with one short, repeated prompt and trusting the resulting capacity number.
- Reporting average latency and ignoring p95 and time to first token.
- Jumping straight to peak load, so the point where the system starts to bend is never seen.
- Running the test on the production key, where it can take quota away from real users.
Check yourself · 2 of 3
During a concurrency ramp, throughput stops rising at 24 users and 429 errors begin at 32. What does this most likely show?
Check yourself · 3 of 3
In a streamed LLM reply, what does time to first token measure?
Practice items, not counted towards your mastery.
Start here
- Rate limits (Claude API docs) (opens in a new tab)DocsFree
Request and token limits per model, usage tiers, 429 errors and the retry-after and remaining-quota headers.
- Rate limits (OpenAI API) (opens in a new tab)DocsFree
How requests per minute, tokens per minute and usage tiers work, and how to back off after a 429.
- Batch processing (Claude) (opens in a new tab)DocsFree
How the asynchronous batch endpoint works, its discount and its completion window.
More for this topic
- LLMPerf: load testing LLM APIs (opens in a new tab)ToolFree
A tool that sends concurrent requests to an LLM endpoint and reports time to first token and throughput.