Topic 3 of 6 · 4 min read
Continuous batching for higher throughput
Goal: Read a throughput-versus-concurrency table and pick the concurrency that meets a latency target.
Continuous batching keeps the GPU busy by adding and removing requests at every generation step, and the price of higher throughput is slower answers for each user.
Check yourself · 1 of 3
What is the key difference between static and continuous batching?
Why it matters
Generating one token for one user barely uses a modern GPU. Most of the time goes to reading the model weights from memory, and that read costs the same whether one request or thirty use it. Serving many requests together shares that cost. So total tokens per second rises with concurrency, while each user's speed falls once the GPU is full.
How it works
Older static batching groups requests, runs them together, and waits for the slowest to finish before starting new ones. A short answer sits idle while a long one finishes. Continuous batching (the idea from the Orca paper, used by vLLM and SGLang) schedules at each step: when a request ends, a waiting request takes its place at once. Few slots are wasted.
The numbers you read
- Throughput: total tokens per second across all users.
- Time to first token (TTFT): how long a user waits before text starts. Queueing and long prompts raise it.
- Inter-token latency: the gap between tokens after that. Above roughly the speed people read, the stream feels slow.
- Concurrency: requests in flight at once.
As concurrency grows, throughput climbs and then flattens. Latency keeps rising. Your job is to find the highest concurrency that still meets the latency target, and cap it there.
Before and after
Weak: "The GPU shows 100 percent use, so we are efficient." That says the GPU is busy, not that users are served well.
Better: measure with your own prompts at 1, 8, 32 and 64 concurrent requests. Suppose the target is 30 tokens per second per user. If a user gets 45 tokens per second at 8 requests and 24 at 32, the safe limit is between them, so you set --max-num-seqs near that point and let the rest queue or route to another replica.
What goes wrong
- Chasing peak throughput. The best total tokens per second often comes with latency users will not accept.
- Benchmarking with identical prompts. Real requests vary in length, and a few long prompts stall short ones.
- Ignoring TTFT. A queue that grows quietly shows up first as a long wait for the first word.
- Measuring one request at a time. A single-request test says nothing about behaviour under load.
Examples
Reading a load test
| Concurrent requests | Total tokens/s | Tokens/s per user | Time to first token |
|---|---|---|---|
| 1 | 60 | 60 | 0.3 s |
| 8 | 380 | 47 | 0.5 s |
| 32 | 900 | 28 | 1.4 s |
| 64 | 1,050 | 16 | 4.8 s |
With a target of at least 25 tokens per second per user, 32 is the highest level that fits. Going to 64 adds 17 percent more total throughput but cuts each user's speed by nearly half, and the first token takes almost five seconds.
A cap in the command
vllm serve my-model --max-num-seqs 32
--max-num-seqs limits how many requests run at once. Extra requests wait in the queue, which you can watch in the metrics.
Key points
- Continuous batching refills freed slots at every step instead of waiting for the slowest request.
- Total throughput rises with concurrency and then flattens, while per-user speed keeps falling.
- Track throughput, time to first token and inter-token latency, not GPU utilization alone.
- Choose a concurrency cap from a load test that uses your own prompt and answer lengths.
- Beyond the cap, queue requests or add replicas rather than slowing everyone down.
Common mistakes
- Reading a high GPU utilization number as proof that users are well served.
- Load-testing with one repeated short prompt instead of a realistic mix.
- Never setting a concurrency cap, so a traffic spike slows every user at the same time.
- Comparing engines or settings by total tokens per second alone.
Check yourself · 2 of 3
A load test shows 28 tokens/s per user at 32 concurrent requests and 16 at 64. Your target is 25 tokens/s per user. What cap fits?
Check yourself · 3 of 3
Users complain that answers take about five seconds to start, then stream fine. Which metric should you look at first?
Practice items, not counted towards your mastery.
Start here
- vLLM documentation (opens in a new tab)DocsFree
The serve command, engine arguments, metrics and parallelism pages for the most widely used open serving engine.
- SGLang documentation (opens in a new tab)DocsFree
Docs for the SGLang server, with prefix caching (RadixAttention) and multi-GPU launch options.
- Efficient Memory Management for LLM Serving with PagedAttention (opens in a new tab)PaperFree
The vLLM paper: why KV cache fragmentation wastes memory and how paging it raises throughput.
More for this topic
- Anyscale: continuous batching for LLM inference (opens in a new tab)ArticleFree
A readable walk-through of static versus continuous batching with throughput measurements.
- Orca: A Distributed Serving System for Transformer-Based Generative Models (opens in a new tab)PaperFree
The OSDI 2022 paper that introduced iteration-level scheduling, the idea behind continuous batching.