Servingcore
Batching: static vs continuous
Serve many sequences per forward pass — and refill slots as soon as one finishes.
What it is and why it exists
Decoding is memory-bound, so processing many sequences per step amortises reading the weights. Static batching waits for the slowest sequence in a batch before starting the next; continuous (in-flight) batching inserts new requests into free slots every step, raising throughput and cutting queueing.
Quick prototype
One request at a time.
In production, at scale
Continuous batching in the engine, max batch size and max tokens per batch tuned for the latency target, and separate deployments for latency-sensitive vs batch traffic.
Vendors and tools
| vLLM / SGLang / TGI / TensorRT-LLM | All implement in-flight batching |
|---|
How it fails
- Batch size so large that per-token latency breaks the SLA
What the interviewer asks next
Why does batching barely slow each token down at first?
At small batch sizes the step time is dominated by reading the weights from memory, which happens once per step regardless of how many sequences share it — until compute becomes the bottleneck.