Explain dynamic batching in inference servers and its trade-off

Inference scheduling and the latency-vs-throughput trade-off.
Dynamic batching launches when a time window or max size is met, improving throughput over static batching, but short ones wait for the slowest.
What's really being asked
This question tests whether you understand the scheduling layer of an inference server and can reason about the throughput-versus-latency trade-offs that define production GPU serving. Interviewers want to see that you know dynamic batching is not magic; it is a heuristic scheduling policy that balances utilization against user-visible latency. They also want to know if you can distinguish it from continuous batching, which is the state-of-the-art approach in modern LLM serving frameworks.
The full answer
First, define dynamic batching as a request-collection strategy that waits for one of two conditions: either a maximum batch size is reached or a timeout window expires. Whichever comes first triggers execution. Second, explain the performance benefit: by amortizing model weight loading across multiple requests, it raises throughput compared to single-request or static batching. Third, state the primary trade-off clearly: because all sequences in a batch start and finish together, short generations are held hostage by the longest one in that batch. This means tail latency can spike and GPU resources may sit idle while waiting for the straggler. Fourth, contrast it with continuous or in-flight batching, where finished sequences are evicted and replaced immediately without waiting for the entire batch to complete.
The mistakes people make
A major red flag is conflating dynamic batching with continuous batching. Another is claiming that dynamic batching eliminates tail latency or solves head-of-line blocking; it does not, because the entire batch is gated by the slowest request. Some candidates also describe it as purely size-based without mentioning the timeout window, which misses the core mechanism that prevents indefinite stalling. Finally, saying it improves latency is usually wrong; it improves throughput at the cost of latency.
What usually comes next
The interviewer may ask how you would tune the timeout and max batch size for a specific workload, or what metrics you would monitor to verify the setting. They might also ask when you would prefer dynamic batching over continuous batching, or how padding and variable sequence lengths affect GPU efficiency in a dynamic batch. Another common pivot is to ask about memory pressure: larger batches increase KV cache consumption, so how do you prevent out-of-memory errors?
A concrete example
Imagine an inference server with a max batch size of 8 and a timeout of 10 milliseconds. At time zero, one request arrives. Under static batching, the GPU sits idle until all 8 slots fill, which could take hundreds of milliseconds. Under dynamic batching, if only 3 more requests arrive within 10 milliseconds, the server launches a batch of 4 at the timeout. Throughput rises because the GPU processes four requests in one forward pass instead of four separate passes. However, if those four requests generate 10, 50, 100, and 200 tokens respectively, the first three finish their actual generation early but cannot return results until the 200-token request completes. That idle waiting time for the short requests is the trade-off.
Interview question
What is the key latency cost of dynamic batching in inference serving?
- a.It eliminates head-of-line blocking by evicting finished sequences and adding new ones immediately.
- b.It increases tail latency because all requests wait for the slowest generation in the batch to finish.Correct
- c.It lowers per-request latency compared to static batching by always executing full batches.
- d.It causes GPU under-utilization by strictly requiring a fixed batch size before execution.
Why? this is the answer
Dynamic batching runs requests together, so shorter generations are held hostage by the longest one in that batch, spiking tail latency. Option A describes continuous batching, a state-of-the-art approach that is commonly conflated with dynamic batching.
Just read this? Test yourself on what you have been reading.
Read the original → bentoml.com
- #mlops
- #inference
- #gpu-serving
- #batching
- #latency
You just looked this up. Could you explain it out loud?
That is the part interviews actually test. Tezvyn takes questions like this one and gives you what the interviewer is really checking, the answer that lands, and the mistake that ends the conversation, in the four minutes before your next meeting.
The iPhone app is on the way
We are building it. Until it lands, nothing here is held back from you: every interview card, your saved cards, streaks and the job board all work in Safari, plus hundreds of free practice quizzes of thirty questions each. Sign in and it all carries over to the app the day it arrives.
Want it as an icon? Tap Share at the bottom of Safari, then Add to Home Screen. It opens full screen and the cards you have read stay available offline.
We are hiring for this. Open roles that interview on mlops — each one lists the topics its interview covers.
See open roles