Copperline's first support copilot was a naive script by Priya Nair, the staff platform engineer: load the model, take one request, generate the full answer, reply, repeat. It worked in testing. In production, one user at a time meant the GPU sat mostly idle while everyone else queued. At an illustrative 40 peak users, the last in line waited through 39 full answers before hers started.
Ana, the support lead, said the copilot felt broken. The GPU graph looked calm. Both were right: the scheduling was not. The fix was not a bigger GPU. It was a serving engine.
A serving engine sits between the HTTP request and the GPU. It decides which requests run, in what order, and how memory is shared. Your service sends a prompt over HTTP, and everything after that is the engine's job: accept and tokenise the prompt, schedule it, prefill it, decode it one token per step, and stream the tokens back as they are produced. Engines in this category include vLLM, TensorRT-LLM and SGLang. They differ in details, so the important thing is the shared jobs, and the handful of ideas that make them fast.
The first idea is continuous batching, and it is the main reason an engine beats Priya's script on the same GPU. A GPU works on many rows at once far faster than on one row, so the engine groups requests into a batch and runs one step for the group. The question is when the group changes. In static batching, a batch runs until every request finishes, then the next batch forms. A request needing 2 tokens waits for a batch mate needing 200. In continuous batching, the engine checks the batch at every step. A finished request frees its slot at once, and a queued request joins the next step.
The worked example makes the difference plain. Six requests reach the copilot at once. One step makes one token per running request. The batch holds at most 3. One request, call it A, needs 8 tokens. The rest need 2 each. Under static batching, A, B and C start at step 0 and run until the longest finishes: 8 steps. B and C waste 6 steps each. D, E and F then run steps 8 to 10. Completions add up to 54. Average: 9 steps. Under continuous batching, A, B and C start at step 0. B and C finish at time 2. D and E join, finishing at 4. F joins, finishing at 6. A finishes at 8. Completions add up to 26. Average: about 4.3 steps. Same GPU, same requests. The average wait is less than half, because finished slots refill instead of idling.
The second idea is how the engine manages memory, because the KV cache decides how many requests can run at once. While a request runs, the model keeps a KV cache: stored key and value data for every token so far, so each new token is cheap to compute. It lives in GPU memory and grows with prompt and answer length. The problem is waste. If each request reserves one long stretch for its worst case length, most of it sits empty, and fewer requests fit. PagedAttention, vLLM's documented approach, splits the KV cache into small blocks, like pages in an operating system. A request uses only the blocks it needs, and freed blocks return to the pool at once. Less waste, so more sequences run at once in the same memory. Prefix caching adds to this: many requests share the same prompt start, such as a system prompt, so the engine caches those blocks and reuses them, skipping repeat prefill.
The third idea is chunked prefill. Prefill is heavy: a long prompt takes a long step, and one huge prefill pauses every other running request. Chunked prefill splits a long prompt into chunks across steps, mixed with decode steps. Long prompts get in, but nobody else freezes. Streaming, meanwhile, sends each token to the caller as generated. Text starts fast and grows, instead of silence then a wall of text. Streaming makes time to first token the number users feel, but it does not make generation faster. Total time is unchanged.
In practice, you will tune three settings. Names vary by engine; the bracketed names are vLLM's documented ones. Max sequences (max_num_seqs) is the most requests running at once. Raise it for throughput, until latency or memory says stop. Max batched tokens (max_num_batched_tokens) is the token budget for one step, shared by prefill chunks and decode. Raise it to admit long prompts faster; lower it to protect decode smoothness. KV cache memory share (gpu_memory_utilization) is the share of GPU memory the engine may use, weights plus cache. Higher means more room for blocks, but less headroom on a shared card. Every one of these has a trade. More sequences per step means more work per step, so per token latency rises even as throughput improves. Doubling concurrency doubles cache pressure. Both effects come from the same knob.
Teams moving from a hand rolled script to a dedicated engine often report the same surprise: the GPU was never the bottleneck, the scheduling was. Keep settings as a small documented set per service, change one at a time, and measure the gains on your own traffic.
The rule to carry on call is simple. Name what is scarce first: slots, blocks, steps, or token budget. Then pick the behaviour or setting that targets it. When the queue is full and the GPU looks idle, the answer is almost never a bigger card. It is the engine in the middle, deciding who runs next.
The full interactive chapter is free at https://deployedlab.dev/lessons/infra-05-serving-engines. It walks one request through the engine step by step, works the static versus continuous comparison in full, and includes a hands-on lab that matches six on-call symptoms to the engine behaviour or setting behind each. There are 79 chapters free with no signup, and the full bundle of 193 chapters is $5 a month or $39 a year at deployedlab.dev.
