Inference terms

Continuous batching: how LLM servers batch

Continuous batching is a scheduling method for LLM serving that admits new requests and retires finished ones at every model step, instead of waiting for a whole batch to finish. Also called iteration-level or in-flight batching, it keeps GPU batch slots filled when responses have different lengths. vLLM, SGLang and llama.cpp all use it, and it is a main reason modern servers reach high throughput per GPU.

A GPU conveyor where finished blocks drop off and new blocks join at every step
Requests join and leave at each step, so batch slots never sit empty. AI-generated illustration.

What continuous batching means

An LLM produces output one token per step, and every request in a batch takes one step together. Requests end at different times: one answer is 20 tokens, another is 800. With static batching, the server forms a batch, runs it until the longest request finishes, then starts the next batch. Short requests sit finished while their slots do nothing, and new arrivals wait outside.

The fix came from the Orca paper (OSDI 2022), which proposed scheduling at the granularity of an iteration instead of a request. After every step the scheduler removes finished sequences and adds waiting ones. Orca paired this with selective batching, which batches only the operations that can be batched across sequences of different lengths. On GPT-3 175B the authors reported a 36.9× throughput improvement over NVIDIA FasterTransformer at the same latency.

Today the idea is standard. vLLM and SGLang schedule this way by design, and llama.cpp's server enables it by default.

References: Yu et al., Orca: A Distributed Serving System for Transformer-Based Generative Models (OSDI 2022) · llama.cpp server README

Static, dynamic and continuous batching compared

Three batching styles are easy to confuse. Dynamic batching, common in general model servers, waits a short time to group requests that arrive close together, then runs them as one fixed batch. It helps for fixed-size work such as image classification, but for text generation it inherits the static problem: the batch lasts as long as its longest output.

Static, dynamic and continuous batching compared
StyleWhen requests joinWhen slots free upFit for LLM generation
Static batchingOnly when a new batch startsWhen the longest request endsPoor: idle slots, long waits
Dynamic batchingGrouped within a short time windowWhen the longest request endsBetter arrival handling, same idle slots
Continuous batchingAt any decode stepAs soon as each request endsGood: slots stay full

References: Yu et al., Orca: A Distributed Serving System for Transformer-Based Generative Models (OSDI 2022)

Worked example: idle slots in a static batch

Take a batch of 8 requests with output lengths of 100, 150, 200, 250, 300, 350, 400 and 500 tokens. A static batch runs 500 steps, giving 8 × 500 = 4,000 slot-steps. Only 2,250 of them produce a token. Useful work is 2,250 ÷ 4,000 = 56%, so 44% of the batch capacity is spent waiting for the longest answer.

With iteration-level scheduling, the slot freed by the 100-token request takes a new request at step 101, and so on. If enough requests are queued, the 8 slots stay close to fully used. The same GPU then produces nearly twice as many tokens over the same time, in this idealized case. Real gains depend on how varied your output lengths are and whether the queue stays full.

Worked example: idle slots in a static batch
Item (8 slots)Static batchContinuous, queue always full
Steps to clear the batch500Slots refilled each step
Slot-steps available4,0004,000
Slot-steps producing tokens2,250Close to 4,000
Useful share56%Close to 100%
Two rows of GPU slots, one with many empty gaps and one packed full
A static batch leaves slots idle until its longest request ends; refilling them recovers that time. AI-generated illustration.

Prefill, chunked prefill and preemption

A new request must first prefill its prompt, which is much heavier than one decode step. If a long prompt runs alone, every decoding user waits. Chunked prefill splits long prompts into pieces and mixes them with decode work. In vLLM's V1 engine it is on by default where possible: the scheduler places decode requests first, then fills the remaining --max-num-batched-tokens budget with prefill, splitting prompts that do not fit.

Memory is the other limit. Every running sequence holds KV cache memory, so the batch cannot grow past what the cache can hold. When it runs short, vLLM preempts requests and recomputes them later, which its guide says can raise end-to-end latency. Block-based allocation with PagedAttention lets far more sequences fit, which is why the two techniques appear together.

References: vLLM documentation: Optimization and tuning · vLLM documentation: vllm serve arguments

Configure continuous batching in vLLM, SGLang and llama.cpp

In vLLM, --max-num-seqs caps the number of sequences processed in one iteration and --max-num-batched-tokens caps tokens per iteration. The optimization guide says smaller token budgets improve inter-token latency, larger ones improve time to first token, and a value above 8,192 suits throughput, especially for smaller models on large GPUs. Lower either setting if you see frequent preemption.

In SGLang, --max-running-requests caps concurrent requests, --chunked-prefill-size sets the prefill chunk and --enable-mixed-chunk mixes prefill and decode in one batch. --schedule-policy picks the order of waiting requests, with fcfs as the default.

In llama.cpp's server, -cb (--cont-batching) is enabled by default and -nocb turns it off. -np (--parallel) sets the number of slots, -1 meaning automatic, and the -c context is shared across them. With the unified KV buffer option (-kvu), slots draw from one shared pool.

Configure continuous batching in vLLM, SGLang and llama.cpp
EngineMax concurrent sequencesPer-step token budgetPrefill handling
vLLM--max-num-seqs--max-num-batched-tokensChunked prefill on by default in V1
SGLang--max-running-requests--chunked-prefill-size--enable-mixed-chunk; --schedule-policy
llama.cpp-np slots (-1 = auto)-b / -ub batch sizesContinuous batching on by default (-cb)

References: vLLM documentation: vllm serve arguments · vLLM documentation: Optimization and tuning · SGLang documentation: Server arguments · llama.cpp server README

How continuous batching changes cost per token

You pay for the GPU by the hour whether its slots are busy or idle. Keeping slots full turns the same hour into more tokens. Using the worked example, and an assumed $2 per GPU-hour plus an assumed aggregate rate of 1,600 output tokens per second when every slot is busy, the static batch delivers 56% of that, about 900 tokens per second.

This is an illustrative calculation, not a measured result. Watch your live numbers: vLLM exports vllm:num_requests_running and vllm:num_requests_waiting, and SGLang exports sglang:num_running_reqs and sglang:num_queue_reqs. A long queue with few running requests usually means memory, not scheduling, is the limit.

How continuous batching changes cost per token
Scheduling (illustrative)Useful slot shareAssumed output tokens/sCost per million at $2/h
Static batching56%900$0.62
Continuous, full queueClose to 100%1,600$0.35

References: vLLM documentation: Metrics design · SGLang documentation: Production metrics

Common misconceptions

The scheduler only helps when there is work to schedule. At one request at a time it changes nothing. It also does not remove the trade-off between batch size and latency; it just stops wasting slots.

Common misconceptions
MisconceptionWhat is actually true
It makes each request fasterIt raises total throughput; per-user speed often drops as the batch grows
A higher --max-num-seqs is always betterToo many sequences can exhaust the cache and trigger preemption
It is the same as dynamic batchingDynamic batching groups arrivals; it still waits for the longest output
It needs special client codeIt runs inside the server; clients send normal requests

References: vLLM documentation: Optimization and tuning

Related terms

The KV cache and PagedAttention set how many sequences can be in the batch. Time to first token rises when new requests wait to join. Tokens per second, measured in aggregate, is the number this method improves. To see the effect on your own traffic, follow the load sweep in benchmark LLM inference.

Checklist and next step

Confirm your server uses iteration-level scheduling. Set a concurrency cap that fits the cache at your typical context length. Tune the per-step token budget for your TTFT and inter-token latency targets. Watch running versus waiting requests and preemptions. Load test with realistic output length spread.

When you know how many concurrent requests one GPU carries, size the rental. NeuraMesh rents GPUs by the hour: choose a GPU, a plan, GPU count, hours and region on rent GPUs, and you receive a confirmed quotation, typically within one business day, with nothing charged until you approve. The compute advisor can suggest where to start.

NeuraMesh prices for these GPUs

NeuraMesh prices per GPU-hour in USD, excluding taxes, as of 2026-11-27. Live prices are on the rental pages.
GPUMemoryData centerValue
RTX 409024 GB$0.46$0.40
L40S48 GB$1.26$0.54
A10080 GB$1.56$0.98
H10080 GB$2.88$2.00

Every order is confirmed in a quotation before you pay. See all GPU prices.

Questions readers ask

What is the difference between static and continuous batching?

Static batching runs a fixed group of requests until the longest one finishes. The continuous approach swaps requests in and out after every decode step, so finished requests free their slot immediately and waiting requests start sooner.

Does vLLM use continuous batching?

Yes. Its scheduler works per iteration, and its main limits are --max-num-seqs and --max-num-batched-tokens. Chunked prefill is enabled by default in the V1 engine where possible.

Is in-flight batching the same thing?

In-flight batching is another name for iteration-level scheduling, used by some engines. The idea is the same: requests enter and leave the running batch between steps rather than in whole batches.

Does llama.cpp support continuous batching?

Yes. The llama.cpp server enables it by default through the -cb flag, and -nocb turns it off. Set the number of parallel slots with -np and make sure the -c context is large enough for every slot, since the slots share it.

Why do requests still queue with continuous batching?

Usually because the KV cache is full or the concurrency cap is reached. Check running versus waiting request metrics, then free memory, lower context length or add GPUs.

Sources and editorial notes

Primary documentation reviewed November 24, 2026. Provider descriptions reflect published documentation. Recommendations are our analysis; worked figures are illustrative unless explicitly stated otherwise. No independent provider benchmark or uptime ranking is claimed.

Read the editorial policy.

Need this GPU? Rent it from NeuraMesh: choose a GPU and plan, get a confirmed quotation, and pay only when you approve. See pricing.