Request batching simulator
An LLM server decodes several sequences together, because reading the weights once for many sequences is far cheaper than reading them once for each. The open question is when the batch changes. Requests ask for different numbers of output tokens, so some finish long before others.
Continuous batching cuts mean latency from 1.47 s to 527.8 ms, 64% less, on the same 16 requests.
- R1, R3, … a request decoding
- R2, R4, … a request decoding
- pad: a finished request still holding its slot
- Blank: the slot is empty
Server and requests
Sequences the GPU decodes together in one step.
Illustrative, not measured. Stands for reading the weights, which does not grow with the batch.
Illustrative, not measured.
0 sends every request at once.
Short outputs are more common than long ones.
The same seed gives the same arrivals and lengths in both modes.
Static against continuous
| Same 16 requests | Static | Continuous |
|---|---|---|
| Finishes everything at | 3.09 s | 1.83 s |
| Slots doing useful work | 49% | 81% |
| Throughput | 72 tokens/s | 123 tokens/s |
| Mean latency | 1.47 s | 527.8 ms |
| p95 latency | 2.19 s | 877 ms |
Static batching starts a batch when the server is free and returns every response when the longest one finishes, so short requests wait and new arrivals queue behind the whole batch. Continuous batching decides again after every step: a finished request leaves at once and a waiting one takes its slot. Latency runs from arrival to the moment the response is returned.
What it shows
An LLM server decodes several requests together, because reading the weights once for many requests is far cheaper than once for each. Requests ask for different numbers of output tokens, so some finish long before others. The question is when the batch changes.
The simulator runs the same requests through static and continuous batching on one time axis. Static batching waits for the longest request. Continuous batching refills a slot after every step. Step times are illustrative, not measured, so read the shapes and ratios.
How to read it
- Each row is a slot, a place for one sequence in the batch. A bar labelled R3 is request 3 decoding.
- A hatched “pad” bar is a finished request still holding its slot in a static batch. The step cost still counts it.
- Blank space is an empty slot. In static batching it appears while the server waits for the batch to end. In continuous batching it appears only when no request is waiting.
- Slots doing useful work is the share of slot-steps spent on a request that still needed tokens. Latency runs from a request’s arrival to its response.
- Play, Step and Restart move the shared clock. The seed fixes arrivals and output lengths, so both modes see the same requests.
Questions
What is continuous batching?
It is a scheduling policy for LLM serving that re-forms the batch after every decode step instead of once per group of requests. A sequence that emits its end token leaves immediately and a queued request takes its place. The Orca paper called it iteration-level scheduling; servers such as vLLM use it by default.
Why does static batching waste capacity?
Output length is not known in advance, so a static batch runs for as many steps as its longest request needs. Shorter requests finish early, but their slots stay occupied and still cost time per step. New arrivals also queue until the whole batch is done.
Does continuous batching change the output of a request?
No. Each sequence is decoded exactly as it would be alone, apart from tiny numerical differences from batching. Only when it runs and what it runs next to changes.
Are the times in the simulator realistic?
They are illustrative. A real step time depends on the model, the GPU, the context lengths and the kernels, and prompt processing adds work that this tool leaves out. The comparison between policies holds as a pattern; measure your own server before sizing anything from these numbers.
What limits how many slots I can use?
GPU memory, mostly. Every running sequence holds a KV cache, so the number of slots is bounded by what is left after the weights. PagedAttention reduces that cost by avoiding wasted cache space, which lets more sequences run together.
Sources
Explore further
- vLLMOpen-source LLM server that schedules requests with continuous batching and PagedAttention.
Last updated
More tools
All tools- estimatorToken throughput estimatorEstimate decode speed, time to first token and total tokens per second for a model on your GPU.Open tool
- simulatorSpeculative decoding simulatorFind the draft length that speeds up LLM decoding most, and watch drafts get accepted or rejected.Open tool
- estimatorQuantisation memory plannerSee how much GPU memory a model needs at each precision, and how many GPUs that takes.Open tool