Model Serving Infrastructure Basics
You'll learn to
- -Understand what a model server does beyond a raw API call
- -Recognize batching and GPU utilization tradeoffs
- -See why continuous batching beats static batching, with a real simulation
A company serving Llama-3.1-70B for enterprise clients gets 5 requests per second on a $30,000 GPU. A competitor claims 50 on the exact same hardware, ten times the throughput. Neither number is about the model itself. It is entirely about how the serving layer schedules work onto the GPU, and getting this layer wrong is one of the most expensive mistakes in production GenAI, since it is pure wasted hardware spend.
A Model Server Is Not Just an API Wrapper
Calling a model directly in a loop, one request fully finishes before the next one starts, badly underuses an expensive GPU, since most of the time is spent waiting rather than computing. A real model server (vLLM and TGI are the two names worth knowing) exists specifically to keep the GPU busy: batching multiple requests together, managing memory carefully, and scheduling work so the hardware is rarely sitting idle.
Static Batching Wastes Capacity on Stragglers
The naive approach, static batching, waits for a fixed-size batch of requests to accumulate, runs them together, and only starts the next batch once every single request in the current one has finished. That last part is the problem: one unusually long generation in the batch holds the entire batch, and the whole GPU, hostage until it finishes, even while every other slot in that batch sits idle waiting.
Adjust the slot count below and watch two real scheduling algorithms, run on the same 30 requests, diverge.
Static vs. Continuous Batching, Same 30 Requests
A few long-running requests ("stragglers") block an entire static batch. Continuous batching refills each slot independently. Both counts recompute live as you change slot count.
Static batching
16 / 30
requests completed in 40 ticks
Continuous batching
30 / 30
requests completed in 40 ticks
Continuous batching finishes 1.88x as many requests in the same window, purely from not letting one slow request hold up the entire slot.
Continuous Batching: Refill the Instant a Slot Frees
Continuous batching (sometimes called in-flight batching) fixes exactly this. The instant any single request in the batch finishes, a new request immediately takes its slot, rather than waiting for every other slot to finish too. No request is ever blocked by a stranger's long generation. This alone is typically a 3 to 5x throughput improvement over static batching on the same hardware.
PagedAttention: Memory as the Other Bottleneck
Batching solves scheduling. The other constraint is GPU memory, specifically the KV cache, the growing memory each in-progress generation needs to hold onto as it produces more tokens. vLLM's signature technique, PagedAttention, manages this memory the way an operating system manages virtual memory: allocating it in small fixed-size pages rather than one large contiguous block per request, so memory is not wasted reserving worst-case space up front. This is what lets a single GPU hold meaningfully more concurrent requests in flight at once.
In practice, you do not hand-roll a scheduler. vllm serve meta-llama/Llama-3.1-70B or TGI's equivalent gives you continuous batching and PagedAttention out of the box. Knowing why they matter is what lets you configure batch size, GPU memory utilization, and max sequence length sensibly, instead of copying a config from a blog post and hoping.
Interview Signal is part of Pro
See a real weak answer next to a real strong one for this exact topic.
Quiz is part of Pro
Test what you just read with a short quiz, and bank the XP.