Inference Engineeringsimulator

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 is faster

Continuous batching cuts mean latency from 1.47 s to 527.8 ms, 64% less, on the same 16 requests.

Throughput gain1.69×123 vs 72 tokens/s
Static batching: a batch runs until its longest request is done
Slot 1Slot 2Slot 3Slot 4R1R2R6padpadR14padR3padR7R11R15R4padR8padR12padR16padR5R9R13pad07731,5452,3183,090ms
Continuous batching: a finished slot refills after the next step
Slot 1Slot 2Slot 3Slot 4R1R6R7R13R15R2R11R3R5R12R4R8R9R14R1607731,5452,3183,090ms
  • 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

Continuous batching, mean latency527.8 ms1.47 s with static batching, 64% less
Useful slots, static49%The rest hold finished sequences or sit empty
Useful slots, continuous81%Free slots refill after every step
Static against continuous batching on the same 16 requests
Same 16 requestsStaticContinuous
Finishes everything at3.09 s1.83 s
Slots doing useful work49%81%
Throughput72 tokens/s123 tokens/s
Mean latency1.47 s527.8 ms
p95 latency2.19 s877 ms
How the two modes differ

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

Your first senior-level
lesson is free.

Choose a course, open a free lesson, and explore an idea you’ve wanted to understand.