Static vs Continuous Batching
What static and continuous batching are, why static batching leaves the GPU idle, and the trade-offs, explained simply for your AI interview.
In short
Static batching sends a group of requests to the GPU and waits for the slowest one before taking new work. Continuous batching swaps in a new request as soon as one finishes, so the GPU stays busy and short replies don't wait.
12 min readIntermediateCommon · estimateFacts checked 26 November 2026
Say it out loud
Read it once, then say it without looking. Start with the short one; use the long one when they ask you to go deeper.
Batching means running several requests on the GPU at once, because one at a time leaves it mostly idle. With static batching, the server waits until every request in the group finishes. One long reply holds up the short ones, and the slots sit empty. With continuous batching, the server checks after every token. A finished request leaves, and a waiting one takes its place straight away. In a made-up run I did, the four slots were in use 83 percent of the time instead of 55. The trade-off is that a long prompt can slow the replies already running, so I'd measure latency as well as throughput.
A GPU is very fast at doing many small jobs at once, so an AI server groups requests together. This is called batching. Requests don't arrive together, and they don't all need the same length of reply. A short status check might need 12 tokens, and a claim summary might need 90. A token is a small piece of text, often a word or part of one, and the model writes one token at a time.
With static batching, the server fills a batch, runs it step by step, and starts the next batch only when every request in the current one has finished. A short reply finishes early, but its slot stays reserved, so its slot does no useful work until the long one ends. The vLLM paper describes the same problem: padding requests to equal length wastes computation and memory.
Continuous batching checks after every step. A request that has finished leaves, and a waiting request takes its slot at once. In a made-up run with 8 requests and 4 slots, static batching kept the slots busy 55 percent of the time over 160 steps. Continuous batching kept them busy 83 percent of the time over 106 steps, with the same 351 tokens of work.
The price is latency. A new long prompt needs a burst of prefill work, which can stall replies already streaming. So I'd check both throughput and latency, and I'd ask whether chunked prefill, which reads long prompts in slices, is needed. I'd start with continuous batching and measure.
What is batching, in plain words?
Batching means giving the GPU several requests at once. A GPU is built to do many small jobs side by side, so when it handles one request at a time, most of its capacity sits idle.
A GPU is the chip that runs the model. Throughput is how much work it finishes per second. Latency is how long one user waits for a reply.
Think of a clinic that books patients in groups of four. In a static clinic, the group is called in together, and nobody new sits down until the slowest of the four has left, so chairs stand empty. In a continuous clinic, a new patient sits down the moment a chair frees up. An AI claims assistant has the same problem. One customer types "Where is my refund for claim 88412 and when will it land?" and another asks for a full policy summary. Both may share one batch, and the short question should not wait for the summary.
A model writes its reply one token at a time. Each request goes through two phases. Prefill reads the whole prompt in one go. Decode writes the reply, one token per step.
Key words
- Batch
- Several requests the GPU works on in the same step.
- Token
- A small piece of text, often a word or part of one.
- Prefill
- Reading the whole prompt in one go, before the first reply token.
- Decode
- Writing the reply, one token at a time.
How does static batching work, and where does it waste time?
The server fills a batch with a fixed set of requests and sends it to the GPU. Every request in the batch moves forward together, one token per step. The batch only ends when its longest reply ends, and the next batch waits until then.
The waste comes from different lengths. A short reply is finished early, but its slot stays reserved, so its slot does no useful work. Engineers also pad short requests with filler so they line up with the longest one, and that filler still costs work.
One batch of four, two ways
Static batching
Batch of 4 starts
all four go in together
Short ones sit idle
they wait for the longest reply
Continuous batching
Batch of 4 starts
the same four requests
Done ones leave
a new request takes the slot
Slots sit empty
55% busy over 160 steps
Slots busy
83% busy over 106 steps
- 1The short requests finish early but keep their slots.
- 2The GPU slots sit empty until the whole batch ends.
- 3Each step, finished requests leave the batch.
- 4A waiting request fills the free slot at once.
What does continuous batching change?
Continuous batching re-forms the batch at every step. The scheduler, the part of the server that decides who runs next, does three jobs each step.
- 1
Drop the finished
A request that has written its last token leaves, and its memory is freed.
- 2
Refill the free slot
A waiting request takes the empty place, so no slot sits idle.
- 3
Run one more token
Every running request writes its next token in the same GPU step.
“Continuous batching maximizes GPU utilization by dynamically rescheduling the batch at every generation step.”
Hugging Face's transformers docs
“A straightforward batching technique would pad the inputs and outputs of the requests to equalize their lengths, wasting GPU computation and memory.”
The vLLM paper, 2023
The idea has several names. The vLLM paper uses the term iteration-level scheduling, from Orca (Yu et al., 2022), for the same per-step idea. NVIDIA's TensorRT-LLM lists in-flight batching as a feature. vLLM itself lists continuous batching among its speed features.
Triton, NVIDIA's inference server, has a dynamic batcher that can hold requests for a set time so others can join the batch. That timed wait is a different mechanism from refilling a slot at every step. Interviewers may mix the two up, so say which one you mean.
Does continuous batching really help?
Here is a made-up run. A server has 4 slots, and 8 requests arrive with replies of 12, 90, 15, 80, 10, 60, 14 and 70 tokens. The script below counts the steps and how many slots do useful work.
- Static
55% of slots busy
160 steps, because each batch of four waits for its longest reply.
- Continuous
83% of slots busy
106 steps, because a finished slot is refilled at once.
Both runs do the same 351 tokens of work. The difference is the empty slots.
# A made-up GPU server with 4 slots in the batch. Each number is how many tokens a
# request still has to write. Real servers also juggle memory; this shows only the scheduling.
REQUESTS = [12, 90, 15, 80, 10, 60, 14, 70]
SLOTS = 4
def static(queue):
steps = busy = 0
for i in range(0, len(queue), SLOTS):
batch = queue[i:i + SLOTS]
steps += max(batch) # the whole batch waits for its longest request
busy += sum(batch)
return steps, busy
def continuous(queue):
steps = busy = 0
todo, running = list(queue), []
while todo or running:
while todo and len(running) < SLOTS: # a free slot is refilled at once
running.append(todo.pop(0))
steps += 1
busy += len(running)
running = [left - 1 for left in running if left > 1]
return steps, busy
for name, run in [("static", static), ("continuous", continuous)]:
steps, busy = run(REQUESTS)
total = steps * SLOTS
print(f"{name:<11} steps={steps:<4} slots busy={busy}/{total} ({busy / total:.0%})")Output
static steps=160 slots busy=351/640 (55%) continuous steps=106 slots busy=351/424 (83%)
What are the trade-offs?
Continuous batching has a cost. Each running request keeps a KV cache, the stored memory of its tokens so far. That cache grows and shrinks as requests come and go, so the server has to track it closely.
The bigger cost is latency. A new long prompt needs a big prefill burst, and that can stall replies already streaming. Prefill is slow per step but saturates the GPU's compute (its math units), while decode is fast per step but uses little of it. The first token is the first piece of the reply the user sees. The Sarathi-Serve paper, from 2024, puts the clash this way:
“batching multiple requests leads to an interleaving of prefill and decode iterations which makes it challenging to achieve both high throughput and low latency.”
The Sarathi-Serve paper, 2024
A long prompt, and the fix
Long prompt arrives
needs a big read before any output
Replies slow down
users mid-reply see long gaps
Read in chunks
a slice of the prompt each step
Replies keep moving
running replies are not paused
- 1A big read takes a burst of GPU work, so replies slow down.
- 2The fix: the long prompt is read in slices, not in one go.
- 3Each slice lets the running replies keep moving at every step.
Sarathi-Serve introduces chunked prefills, which splits a prefill request into near equal sized chunks. Those chunks let new requests join a batch without pausing ongoing decodes. The cost is plain: chunking spreads the long prompt over several steps, so its own first token can come later.
Tip
Asked how to keep a chat fast under load? Name the trade-off first: throughput is how much work the GPU finishes, and latency is how long one user waits. Then say you would measure both.
How would you serve a chat app and an overnight report job?
Two workloads share one GPU fleet. The chat app needs replies to start quickly, so it gets continuous batching with chunked prefill. The overnight job only cares about total work finished by morning, so a big batch with long waits is fine.
- Live chat
Latency first
Continuous batching, with long prompts read in chunks so replies keep moving.
- Overnight job
Throughput first
Large batches that keep the GPU full, and nobody is waiting on one reply.
What does the interviewer want to hear?
A strong answer covers
- Batching runs several requests on the GPU together.
- Static batching waits for the longest request, so slots sit empty.
- Continuous batching refills a slot at every step.
- The trade-off: memory for each running request, and slower first tokens when long prompts arrive.
- Throughput versus latency, and how chunked prefill helps.
- Names the tools: vLLM, TensorRT-LLM's in-flight batching, Triton's dynamic batcher (a timed wait, not per-step refill).
Common traps
Trap"Static batching is faster, because the whole group finishes together."
BetterFinishing together only helps the slowest request. Continuous batching keeps idle slots filled, so more work is done per second.
Trap"Continuous batching has no downside."
BetterIt adds memory for each running request, and it can slow replies when a long prompt arrives.
Trap"Just buy a bigger GPU."
BetterA bigger GPU still wastes slots when short and long requests share a static batch.
Can you spot the waste?
Spot the waste
A batch holds three 12-token tag requests and one 900-token summary. Which setup leaves the most GPU slots empty?
Quick check
A chat app gets new long prompts all day, and users say replies freeze. What is the best first change?
Can you answer these from memory?
Flash cards · tap a card to flip it
What will they ask next?
- Q315Why stream tokens?12 min
- Q316TTFT vs tokens/sec vs total latency?12 min
- Q317The latency vs throughput trade-off?Coming soon
- Q319What is PagedAttention / vLLM?Coming soon
- Q320Serving engines (vLLM, SGLang, TensorRT-LLM, llama.cpp)?Coming soon
Learn it in depth
Last updated on 26 November 2026
Serving an AI feature to real users?
I design and build AI products and agents, including how they run in production. Book a short call and tell me how many users you expect and how long the replies are.