What is continuous batching in LLM serving?
Continuous batching changes which LLM requests are processed together at each iteration, freeing capacity when a response ends so others can be served at once.
Continuous batching, also called in-flight batching, is a technique that updates, at every step, the group of requests a language model processes together. When one response finishes, the serving engine can admit a new request without waiting for the others. With static batching, later arrivals wait for the entire group to finish, even if some responses are already complete. Processing happens on a GPU, the accelerator chip that performs the model's computations. Responses are generated one token at a time, that is, one fragment of text per step. The Orca project proposed this iteration-level scheduling in 2022. This way, multiple requests can share the GPU without leaving the capacity freed by shorter ones idle. The result is higher throughput, meaning more requests served per second, but the added capacity can affect how smoothly responses already in progress are delivered.
See also: InferenceAI inference applies a trained model to new data to produce predictions or responses; latency and cost depend on the workload and the infrastructure behind it.
How iteration-level scheduling works
At each iteration the engine removes completed requests and can add new ones. A queued request can join after one step rather than waiting for the entire group. Each request occupies GPU memory in the KV cache, the memory that stores results already computed for earlier tokens, so available memory limits how many requests can run concurrently. The vLLM paper found that in earlier systems only 20.4% to 38.2% of KV cache memory held actual token states, compared with 96.3% using PagedAttention, the memory management approach that helped make continuous batching practical in vLLM.
Why throughput rises without changing hardware
Requests take different amounts of time. When a short response finishes, its slot goes to a waiting request while the others continue. The same GPU can therefore handle more work instead of waiting on the longest response. The benefit depends on available memory and workload.
The latency trade-off in vLLM
Each request goes through prefill, which processes the initial prompt, and decode, which generates the response one token at a time. As Sarathi-Serve shows, a prefill joining the group can temporarily stall responses mid-generation. Chunked prefill splits the prompt into chunks to limit these stalls; Dynamic SplitFuse also tackles the problem by scheduling prompt chunks alongside generation.
According to the vLLM documentation, the V1 engine enables chunked prefill by default whenever possible: it schedules pending decodes first, then gives prefills the tokens left in the per-step max_num_batched_tokens budget, splitting any prefill that does not fit. A smaller budget improves ITL, while a larger one improves TTFT; for throughput the documentation recommends a value above 8192, especially for smaller models on large GPUs. The metrics are explained in the entry on prefill and decode. If KV cache memory runs out, vLLM can preempt requests and recompute them later, increasing end-to-end latency. Lowering max_num_seqs or the token budget can reduce concurrency and ease the problem.
An enterprise example
A company hosts a model on its own servers for short chat turns and requests containing long documents. When a long document arrives, responses already underway show ITL spikes. The team tries smaller token budgets, accepting higher TTFT on long documents. It also tracks preemptions and, if needed, lowers max_num_seqs. Then it compares capacity and latency on the same mix of request and response lengths expected in production.
Why it matters for decision makers
A throughput figure without a latency target is not enough to evaluate a service. The DistServe paper uses per-GPU goodput: the maximum request rate served while a fixed share of requests (90% in its tests) stays within TTFT and time-per-token limits. To evaluate a vendor or a self-hosted setup, ask for or measure requests per second per GPU while a fixed share of requests meets your TTFT and ITL targets, on your own mix of lengths.
Frequently asked questions
Related terms
- InferenceAI inference applies a trained model to new data to produce predictions or responses; latency and cost depend on the workload and the infrastructure behind it.
- KV cacheThe KV cache stores a language model's intermediate attention values so the model does not recompute them as it generates an answer, one token at a time.
- FlashAttention vs PagedAttentionFlashAttention reduces data transfers in the attention computation; PagedAttention reads the KV cache as non-contiguous blocks allocated as they are needed.
- Prefill, decode, TTFT and ITLPrefill and decode are the phases that process the prompt and generate the answer; TTFT and ITL measure the initial wait and the gaps between streamed outputs.
- vLLM, SGLang and llama.cppvLLM for GPU throughput, SGLang for requests sharing the same context, llama.cpp for CPU and edge hardware.