The AI-Native track took you inside a single model call — prefill, decode, the KV cache, the throughput-latency dial. This chapter climbs one level up, to the layer you actually operate: the server, the queue, the scheduler, the fleet. Your job here is not to make one forward pass fast; it is to keep expensive GPUs full, requests moving, and an SLO holding while traffic swings by 10x across the day.
A production inference server is not a wrapper around model.generate(). It is a small distributed system with four jobs stacked behind one HTTP endpoint. It exposes an OpenAI-compatible API so clients are portable, it runs an admission layer and queue that decides who gets on the GPU, it runs a scheduler that rebuilds the running batch every iteration, and it runs a paged KV-cache manager — PagedAttention — that hands out attention memory in fixed blocks so sequences of any length pack tightly, wasting at most part of one block per sequence instead of a max-length reservation. Tokens leave over a streaming connection the instant they are produced.
We covered why prefill and decode differ in the AI-Native serving chapter; here the point is where they live. The API layer and streamer are cheap and CPU-side. The value — and the entire operational difficulty — sits in the hot loop of scheduler, batched execution, and KV management, which runs continuously for as long as the server is up.
OpenAI-compatible API
POST /v1/chat/completions · auth · validate · tokenize
Admission + queue
backpressure · max-num-seqs · reject when full
Scheduler
picks which sequences run each iteration
Execution engine
batched forward pass on the GPU
Paged KV-cache manager
PagedAttention — blocks of attention state
Token streamer
SSE — first token out, then the rest
Steps 3–5 run thousands of times per second — the scheduler, the batched forward pass, and the KV-cache manager form the tight loop that decides your throughput and your cost per token.
"Cheap and CPU-side" stops being true at high concurrency, and the failures it produces are misattributed to the GPU. Tokenizing a 30k-token RAG prompt, detokenizing incrementally for a few hundred concurrent streams, and serialising SSE frames all run in a host process that, in Python-based engines, contends for one interpreter lock with the scheduler that feeds the GPU. The symptom is distinctive: inter-token latency rises while GPU utilization falls, because the GPU is waiting on the host to assemble the next step. The engines have been moving tokenization, detokenization and the API server into separate processes for exactly this reason. When you see it, the fix is more API-server processes per engine or a newer engine version, not more GPUs.
The second host-side failure costs more money. A user closes the tab, a gateway times out at 60 s, a client library retries after its own deadline. Unless the disconnect propagates to the engine and aborts the sequence, the GPU keeps decoding to max_tokens for nobody, holding KV blocks that a live request is queued behind. Under overload this is self-amplifying: the slower the service, the more clients give up, and the more of the running batch is abandoned work. Check it end to end, through every proxy and every gateway, because one buffering hop that does not forward the close is enough to break it. The useful metric is aborted-sequence tokens as a share of generated tokens. If it is above a few percent at peak, timeouts somewhere in the path are shorter than the generation they are waiting on.
A GPU can only run so many sequences at once. There are two ceilings, and people conflate them: max-num-seqs is a configured cap on running slots, while the real ceiling is the number of KV-cache blocks free at this instant. Effective concurrency is the minimum of the two, and the second one moves with every request's length. Everything that arrives beyond it goes into a queue. This is the single most important operational fact of serving: your requests spend real time waiting before the model ever touches them, and that wait is invisible in per-token latency metrics.
Queue depth and time-in-queue are your leading indicators. They rise before p99 latency does, before the GPU shows any distress, before users complain — which makes them the right thing to alert and autoscale on. Two failure modes live here. Head-of-line blocking: one long generation pins a slot and starves everyone behind it, so you want priority lanes and preemption for short or interactive traffic. And unbounded queueing: if you never reject, latency grows without limit under overload, so a healthy server has admission control — past a depth threshold it sheds load with a fast 429 rather than accepting work it cannot finish in time.
Queue · depth = 7
Running · 4 slots (max-num-seqs)
slots capped by KV-cache memory, not CPU
Queue depth and time-in-queue are your leading indicators of overload — they climb before latency does. A slow, long request holding a slot causes head-of-line blocking for everyone behind it, which is why priority lanes and bounded queues matter more than raw replica count.
Size the slots before you size the fleet. Little's law does the first cut: resident sequences = arrival rate × time each sequence stays resident. Illustratively, 20 req/s with a 500-token answer streamed at 40 tok/s per sequence (about 12.5 s resident, plus prefill) means roughly 250 sequences in flight at steady state. The KV budget then converts sequences into replicas, and this is where context length dominates the answer.
Worked example · illustrative
bytes / token
2 (K,V) × 80 layers × 8 kv-heads × 128 dim × 2 B
= 327,680 B ≈ 320 KB
KV budget
≈ 70 GB left after FP8 weights + activations on 2×80 GB
resident tokens
70e9 / 327,680 ≈ 213k
concurrency
213k ÷ avg (prompt + output) tokens
Without GQA (64 KV heads) the same model needs 8× the KV per token — the architecture choice is a capacity choice.
Capacity is inversely proportional to resident tokens per sequence. A product change that raises the average prompt from 2k to 8k (bigger RAG context, longer chat history) quietly cuts per-replica concurrency by 4× with no code change on the serving side — plan capacity in tokens, not requests.
With the numbers above, 250 sequences at a 4k average footprint needs about 5 replicas running at 100% of KV, which means zero headroom and continuous preemption. Target 70–80% KV occupancy at peak and you need 6–7. The same traffic at an 8k average footprint needs 12–14. Most "we need more GPUs" escalations turn out to be a context-length regression upstream: a retrieval change that doubled chunk count, or a chat product that stopped truncating history.
What happens when the KV pool runs dry mid-generation matters more than any steady-state number. Running sequences grow a token at a time, so the scheduler can admit a batch that fits now and not fit three hundred steps later. vLLM-style engines then preempt: they evict a running sequence's blocks and either swap them to host memory or, more commonly, throw them away and recompute the prefill when the sequence is rescheduled. Recompute is cheap for one sequence. Under sustained pressure it becomes a feedback loop: the GPU spends its time re-prefilling work it already did, output falls, the queue grows, clients time out and retry, and offered load rises exactly when capacity has fallen.
1
Burst / long-prompt mix shift
queue time ↑, GPU looks fine
2
KV blocks exhausted
KV usage pinned at ~100%
3
Scheduler preempts running seqs
preemption count ↑ (recompute)
4
Re-prefill burns the GPU
tokens/s ↓ while GPU util stays high
5
Clients time out and retry
request rate ↑ with no new users
6
Goodput collapses
every request finishes late or not at all
The trap is step 4: GPU utilization stays high throughout, so a dashboard built on utilization says the fleet is busy and healthy while useful output falls. Watch preemptions/s and goodput, not utilization.
Architect's note
Where to put the rejection threshold is a queueing question with a concrete answer. A request's TTFT is time-in-queue plus its own prefill. If the TTFT SLO is 2 s at p95 and prefill of a typical prompt takes 300 ms, the queue budget is about 1.7 s, and any request that has waited longer than that is already a miss. Serving it anyway spends GPU time on an answer the client has probably abandoned and delays the requests behind it into misses too. So shed on predicted wait, not on a request count: queued prefill tokens divided by the replica's measured prefill rate gives an expected wait, and a request whose expected wait exceeds its budget gets a 429 immediately, while it can still be retried elsewhere. Propagate the client's deadline with the request and drop queued work whose deadline has passed. Both are cheap, and together they convert the collapse curve above into the plateau.
The 429 only helps if the client does not turn it into more load. An SDK default of three immediate retries, landing on a fleet that is still overloaded and so shedding them again, turns a 10% shed rate into up to 1.3× offered load (1 + 0.1 × 3) at exactly the moment capacity is short. Give clients a retry budget (retries capped at a small percentage of requests, not per request), honour Retry-After, and make retries go to a different replica or region. And separate traffic classes before the queue, not inside it. A single FIFO shared by an interactive chat product and a nightly batch-eval job means the eval job's 10,000 long prompts sit in front of users. Give interactive traffic a priority class that the scheduler admits first and preempts last, and cap batch traffic at a share of KV blocks, so batch absorbs spare capacity instead of competing for the peak.
Continuous batching is usually drawn as a timeline of requests entering and leaving. From the scheduler's seat it is better understood as a per-iteration slot assignment: at every decode step the scheduler looks at the running set, evicts finished sequences, admits waiting ones into freed slots, and assembles one combined forward pass. The batch is not a thing you submit; it is reconstituted from scratch thousands of times a second.
Read the matrix below column by column — each column is one GPU iteration. Notice two operational moves. First, a freed slot is reused immediately: when a sequence finishes, the next waiting request joins on the very next step, which is what keeps utilization high. Second, chunked prefill — a long prompt is split across several iterations and interleaved with ongoing decodes, instead of monopolizing one giant step. Without chunking, a single 8k-token prompt arriving mid-stream would freeze every user's decode for the duration of its prefill; chunking is the operational lever that keeps prefill spikes from wrecking tail latency.
The batch is rebuilt every iteration, not per request. When seq A finishes, its slot is handed to a waiting sequence the very next step. Chunked prefill splits a long prompt across several iterations so one big prompt does not stall every in-flight decode — the operational fix for prefill spikes hurting tail latency.
The knob behind chunking is a per-step token budget (max-num-batched-tokens in vLLM): each iteration processes every running sequence's single decode token plus as many prefill tokens as fit in what is left. That makes the budget the dial between two users who never see each other. Work it through for a 70B FP8 model on two GPUs, with illustrative numbers: the step has a ~10 ms floor from reading the weights, and prefill costs about 2 × 70 billion FLOPs per token, roughly 0.07 ms per token at an effective 2 PFLOP/s across both GPUs. An 8k prompt admitted whole makes one step of ~580 ms, so every streaming user sees a half-second freeze. At a 512-token budget the same prompt takes 16 steps of ~46 ms each.
Prefill tokens / step
Step time = every in-flight user's inter-token gap
Steps for 8k
8k prompt TTFT
512
16
≈ 0.74 s
2,048
4
≈ 0.61 s
8,192 (unchunked)
1
≈ 0.58 s
model: step ≈ 10 ms (weight read) + 0.07 ms × prefill tokens · 2 × 70e9 FLOP/token at ~2 PFLOP/s effective across 2 GPUs · labels illustrative
The long prompt's TTFT moves by ~25% across the range; every other user's inter-token gap moves by 12×. Chunking is almost free for the request being chunked and decisive for everyone sharing the GPU with it — which is why the budget is a tail-latency setting, not a throughput one.
The asymmetry is the whole point. The long prompt's own TTFT barely changes, because its prefill is compute-bound and the FLOPs are the same whichever way they are sliced; it only pays the extra weight-read floor per chunk. Everyone else's inter-token latency moves by an order of magnitude. Set the budget from the ITL SLO: if p99 inter-token latency must stay under 60 ms and the decode-only step is 15 ms at your batch, the prefill share of a step can be about 45 ms, which is ~640 tokens under these assumptions. Go smaller and the per-chunk floor starts to dominate throughput. The failure mode on the other side is a budget tuned on a benchmark of uniform short prompts, which never exercises chunking at all, and then meets production RAG traffic.
Two larger topology decisions sit on the same axis. Disaggregated prefill and decode runs them on separate replica pools and ships the KV cache between them, so prefill spikes cannot touch decode at all and each pool can be sized and even specced separately. The cost is a KV transfer per request (for the illustrative 70B model, ~320 KB per token, so an 8k prompt is ~2.6 GB to move) and a second capacity plan to keep in balance. It earns its complexity when prompts are long relative to outputs and the ITL SLO is strict: long-context RAG, summarisation, agents with large tool outputs. For chat with short prompts, chunked prefill on a unified pool gets most of the benefit with none of the transfer. Treat it as a threshold decision: if chunked prefill cannot hold the ITL SLO without cutting the budget into the throughput floor, disaggregate.
Speculative decoding is the other one, and it is where conventional advice is most often wrong. It trades spare compute for fewer sequential steps: a draft proposes several tokens and the big model verifies them in one pass. At small batch, where decode is memory-bound and the tensor cores idle, the verification is nearly free and per-user speed can rise substantially. At large batch the spare compute is gone; every rejected draft token is FLOPs taken from other users, and aggregate throughput can fall. So speculation is a low-load optimisation. Enable it for latency-sensitive, lightly batched tiers, and verify that your engine disables or scales it back as the batch fills, rather than turning it on fleet-wide because a single-stream benchmark looked good.
You are renting the most expensive compute in the building, so the number that matters is tokens per GPU-second, or equivalently MFU — the fraction of the hardware's peak FLOPs you actually convert into output. It is routinely under 50%, and knowing where the rest goes is how you get it back. Decode is memory-bandwidth-bound: every step streams the full weights (and each sequence's KV) out of HBM to produce one token per sequence, so at small batch the compute units idle. That makes MFU the wrong gauge for decode-heavy serving. The honest one is MBU, achieved bytes/s against peak HBM bandwidth. A decode step can sit at a single-digit MFU and still be near the hardware limit. Padding, the classic static-batching tax, is mostly gone in engines that flatten a batch into one ragged token stream. What remains is under-filled steps when the batch is small, prefill/decode interference within a step, and launch and scheduler bubbles, which CUDA graphs and async scheduling shrink without eliminating.
A back-of-envelope ceiling (illustrative, H100-class HBM at ~3.35 TB/s): a 70 GB FP8 model split over two GPUs streams ~35 GB per GPU per step, about 10 ms, so a sequence decodes at roughly 100 tok/s at best, regardless of batch size, until the batch gets large enough to turn compute-bound. Batching does not make any one user faster. It amortises the same weight read across more users. That is why cost per token falls steeply with batch size and per-user speed barely moves, until KV reads, which do scale with batch × context, start to dominate the step.
Where does decode stop being memory-bound? Illustratively, an H100-class part offers on the order of 2 PFLOP/s dense FP8 against ~3.35 TB/s, a ridge of roughly 600 FLOPs per byte. With FP8 weights, each weight byte read is used for about 2 FLOPs per sequence in the batch, so the weight matmuls reach the ridge somewhere around a batch of 300. Attention never gets there during decode, because each sequence reads its own KV, which is not shared across the batch. The practical consequence is that nearly every production decode deployment lives on the memory-bound side of the roofline, and the thing that ends the batch curve is KV capacity, long before compute.
Model: step ≈ 10 ms weight read + ~0.1 ms per sequence of KV read (2k tokens × 320 KB, split over two GPUs at ~3.35 TB/s), GPUs at an illustrative $3/hr each. Going from batch 1 to 104 cuts cost per token ~50× and per-user speed by half. The curve ends not at the compute roofline (hundreds of sequences away) but at the KV budget.
The obvious fix — a bigger batch — collides with a hard wall. GPU memory holds the weights (fixed) plus the KV cache, and the KV cache grows with batch size times sequence length. So the very thing that would raise utilization is capped by the same memory it competes for. This is why the KV-cache ceiling sets your max concurrency, why long contexts are disproportionately expensive to serve, and why quantization and paged attention pay off twice — they shrink the memory footprint and unlock a bigger batch.
One GPU-second, broken down · illustrative split
Only the green band is billable work. MFU is the fraction of peak FLOPs you actually convert to tokens — often well under 50%.
The KV-cache ceiling
Bigger batches would raise utilization — but the KV cache eats the same HBM. Memory, not compute, sets your max concurrency.
The operating point is therefore a product decision expressed as a batch size. Pick the per-user streaming floor first: if the product needs 50 tok/s per stream to feel faster than reading, the curve above says batch ≤ ~100 on this hardware at 2k context, and cost per token follows from that, not the other way round. Two tiers on the same model then become an honest option: an interactive tier held at batch ~32 (~76 tok/s per user), and a bulk tier (evals, backfills, async summarisation) run at whatever batch the KV budget allows. In the illustration the per-token cost gap is about 2× on identical hardware, more for bulk jobs with short contexts where the KV wall sits further out. That, not marketing, is the defensible basis for pricing batch APIs lower.
Where the conventional advice is wrong
The default autoscaling instinct — scale on CPU — is actively wrong for inference. The GPU is the bottleneck while the CPU sits nearly idle, so a CPU-based rule adds replicas far too late, after the queue has already blown up. Scale on the signals that actually track saturation: queue depth, time-in-queue, or KV-cache utilization. These form a clean control loop — the metric drives a controller, the controller changes replica count, more replicas drain the queue, and the signal falls back to target.
The complication that makes GPU autoscaling its own discipline is the cold start. Adding a replica means scheduling a GPU pod, pulling a large image, and loading tens of gigabytes of weights into HBM — that last step alone takes minutes. So a new replica is useless exactly when you need it most. Two consequences follow. Scale-to-zero saves money on idle models but inflicts a multi-minute first-request latency, acceptable only for background or dev traffic. And for anything interactive you must overprovision headroom and scale ahead of demand — on a trend or a schedule — because reactive scaling always arrives late.
The control loop
Never scale on CPU — the GPU is the bottleneck and CPU stays low while requests pile up. Scale on queue depth, time-in-queue, or KV-cache utilization.
Cold-start timeline for one new replica
The weight load dominates — minutes, not seconds. That is why scale-to-zero trades cost for a brutal first-request latency, and why you keep warm headroom and scale ahead of demand rather than reacting to it.
The three signals do not behave the same. KV-cache utilization is a poor proportional signal: a well-tuned server runs it near its ceiling under ordinary load, so it saturates and stops telling you how far over capacity you are. Waiting-request count lies when request sizes vary by 100×, because ten queued 50-token classifications are not ten queued 30k-token summaries. Time-in-queue at p90, or queued prefill tokens, tracks the thing users feel and scales with the size of the backlog. Use it as the primary signal and KV utilization as a guard.
Then do the arithmetic on time-to-ready, because it sets your headroom. Illustratively: a 30–60 s metrics window and controller sync, 0 s to many minutes to get a GPU node (zero if a warm node exists, unbounded if the cloud has no capacity in the zone), 1–3 min to pull a CUDA-heavy image that was not cached on the node, and 140 GB of FP16 weights at an effective 1–2 GB/s from object storage is another 70–140 s before graph capture. Call it 4–8 minutes on a warm node pool and much longer on a cold one. The sizing rule follows: headroom ≥ peak ramp rate × time-to-ready. If morning traffic climbs 3% of peak per minute and a replica takes 6 minutes, you need ~18% spare capacity already running, or the SLO breaks every morning while the autoscaler is doing exactly what it was told.
Both fleets trigger at the same moment and get their replicas at the same moment. The difference is 18 points of capacity that was already running — exactly 3%/min × 6 min. Shorten time-to-ready and the headroom you must pay for shrinks proportionally; that is the business case for warm node pools and local weight caches.
The formula has a consequence that finance teams find counter-intuitive: headroom cost is set by your slowest ramp and your slowest replica, not by your average utilization. A fleet with a 6-minute time-to-ready and a 3%/min ramp carries ~18% idle capacity through every ramp, whatever its daily average. Halve time-to-ready and you release half of that. At a fleet of, say, 50 GPUs, 9 GPUs of permanent headroom is a large number, which is why a platform team can often justify local NVMe weight caches and pre-warmed nodes on headroom savings alone before counting any latency benefit. Where traffic is predictable (business hours, a known daily curve), a scheduled floor that raises minimum replicas 15–30 minutes before the ramp beats any reactive signal, and the reactive loop then only has to handle the residual.
The levers that shrink time-to-ready are unglamorous: pre-pulled images and a warm pool of GPU nodes, weights on local NVMe or a node-level cache rather than fetched per pod, and streaming or memory-mapped weight loading. Each one cuts the headroom you must buy. Scale-in deserves the same care. Draining a replica with in-flight 10k-token generations means either waiting minutes or dropping work, so use long stabilisation windows and graceful drain that stops admission and lets running sequences finish.
Two second-order effects catch teams after the autoscaler works. First, scaling changes the cache, not just the capacity. A new replica starts with an empty prefix cache, so for its first minutes it does more prefill per request than its warm neighbours, and a load-aware router that sends it traffic by queue length sees it as slower. Scale-in does the opposite damage: it destroys the warm prefixes of every conversation pinned to that replica, and those conversations re-prefill their history elsewhere, briefly raising load on exactly the replicas that were meant to absorb the drained work. Second, oscillation. Queue-time signals respond within seconds while capacity responds in minutes; a controller tuned with a short scale-down window will remove a replica during a brief lull, and pay the full time-to-ready to get it back ten minutes later. Asymmetric windows (scale out fast, scale in over 10–30 minutes) are the standard cure, and the right scale-in window is at least a few multiples of time-to-ready.
Real platforms serve dozens of models — different sizes, different fine-tunes, embeddings, rerankers, speech. You cannot give each its own dedicated GPU pool; the fleet has to be heterogeneous. The split is by load and swap cost. A handful of big, steadily-used models get dedicated replicas because their traffic justifies the GPUs and reloading them is too slow to do on demand. The long tail of small and fine-tuned models is multiplexed: several share a GPU and are swapped in and out by LRU, so cold or rarely-hit models pay a swap-in penalty on their first request but cost nothing while idle.
A single gateway routes by model name and hides all of this — auth, rate limiting, retries, and the choice of dedicated versus multiplexed backend all live behind one endpoint. The common fleet shape ends up being one big model plus many small ones: the big model handles the hard general traffic on dedicated hardware, while cheap specialized models absorb the high-volume narrow tasks on shared GPUs. Getting this mix right is one of the largest levers on a platform's cost per request. Many fine-tunes of one base are better served as adapters on a shared base than as separate models; that pattern belongs to Fine-tuning & Adaptation.
Gateway
route by model name · auth · rate-limit · retry
Dedicated · big models, steady load
llm-70b
2× replica · dedicated GPUs
llm-8b
3× replica · dedicated
Multiplexed · many small models, LRU swap on shared GPUs
embed-v3
hot
rerank-sm
hot
llm-3b-ft-acme
LRU
llm-3b-ft-globex
LRU
whisper-lg
cold → swap in
The fleet is rarely uniform: a couple of big models get dedicated GPUs because their load is steady and swapping them is too slow, while a long tail of small and fine-tuned models shares GPUs and is swapped in and out by LRU. Routing by model name lets the gateway hide all of it behind one endpoint — the cost is a cold-swap penalty on the first hit to an evicted model.
The dedicated-versus-multiplexed line is a cost comparison you can write down. A dedicated replica costs its GPU-hours whether or not it is used; a multiplexed model costs its share of busy time plus a swap penalty paid in latency on each cold hit. Two numbers decide it. The first is duty cycle: the fraction of hours in which the model has enough concurrent traffic to form a useful batch. The second is mean inter-arrival gap versus eviction horizon: if requests arrive more often than the LRU would evict the model, it is effectively resident anyway and multiplexing buys nothing but risk. As an illustrative rule, a model whose traffic would keep a dedicated replica meaningfully busy for more than about a third of the day, or whose p99 latency budget cannot absorb one cold swap, should be dedicated. Everything below that line should share.
Time to move 16 GB of weights into HBM · transfer only, excludes engine init
Host RAM → HBM
PCIe, ~25 GB/s effective
~0.6 s
Local NVMe
~3–7 GB/s
~2–5 s
Object storage
~1–2 GB/s effective
~8–16 s
Mode
Fits when
Cold penalty
Breaks when
Dedicated replicas
Load keeps a replica's batch useful most hours; model too big to swap
None steady-state; minutes to add a replica
Idle GPUs overnight; headroom per model does not pool
Multiplexed (LRU swap)
Many small models, each idle most of the time
One swap per cold hit — the tier table above
Thrash when the hot working set exceeds HBM: every request pays a swap
Adapters on a shared base
Many fine-tunes of one base model
Adapter load ≪ model load
One base version for all tenants; rank and batch mixing cost throughput
Managed API / serverless
Spiky, low-volume, or pre-product-market-fit
Provider's problem, provider's latency
Per-token price at scale; no control of tail or version
The transfer is rarely the whole cold cost: engine start-up, memory profiling and CUDA-graph capture can add as much again unless the server is built to swap models in a running process. Measure cold-hit latency end to end before deciding a model can be multiplexed.
Multiplexing fails abruptly rather than gradually, and the mechanism is thrash. Say a node with 80 GB of HBM hosts a pool of 8B models at ~16 GB each plus KV. It can keep three or four resident. As long as the models touched within any swap-time window fit, the LRU works and cold hits are rare. Add one more tenant model with steady traffic, or let a batch job iterate over all of them, and the working set exceeds HBM: each request evicts the model the next request needs, the GPU spends its time copying weights, and latency for every model on the node jumps by the swap time at once. The symptom is swap-ins per minute approaching requests per minute, and it is the metric to alert on. Mitigations in order of cost: keep the hot set explicitly pinned rather than trusting LRU, shard models across nodes by traffic so each node's working set fits, route batch jobs that sweep many models to a separate pool, and for fine-tunes of a common base, stop swapping models and serve adapters on one resident base.
The fleet mix is also where model choice becomes an operations lever. Per output token at the same precision, an 8B model streams roughly a ninth of the weight bytes of a 70B and its KV per token is proportionally smaller, so the same GPU serves many times the concurrent sequences. Routing the high-volume, narrow tasks (classification, extraction, reranking, short rewrites) to small models is frequently a larger cost reduction than any server tuning in this chapter. The operational requirement it creates is a gateway that knows which task each request is and can fall back to the large model when the small one's output fails validation, which is the routing half of Reliability, Cost & Rollouts.
Once one model has more than one replica, the policy that picks a replica decides tail latency as much as the scheduler does. Generic L7 balancing assumes requests cost roughly the same. LLM requests vary by two to three orders of magnitude in resident tokens, so round-robin produces a fleet where one replica is preempting while its neighbours sit half-empty, and the aggregate dashboard averages the two into something that looks fine.
The second reason is prefix caching. Engines that keep the KV of previously seen prefixes can skip prefill for any request that shares one: a long system prompt, the earlier turns of a conversation, an agent's growing scratchpad. That cache lives on one replica. Send turn 7 of a conversation to a different replica from turns 1–6 and you pay the whole prefill again. For agentic and multi-turn workloads, where the prompt is mostly history, cache-aware routing is often the largest single TTFT and GPU-cost lever available without touching the model.
Policy
Signal
Failure mode
Use when
Round-robin
none
Ignores that one request is 50 tokens and the next 50k; hot replicas preempt while neighbours idle
Homogeneous short requests only
Least outstanding requests
in-flight count
Counts requests, not tokens — a replica with 3 long-context jobs looks emptier than one with 10 short ones
Default for mixed traffic when nothing better exists
Load-aware (queue / KV)
scraped queue time, KV usage
Scrape interval makes signals stale; herding when every router picks the same 'emptiest' replica
Heterogeneous prompts, >4 replicas
Prefix / cache-aware
prompt-prefix hash + load
Popular prefix concentrates on one replica; needs a load cap to spill over
Shared system prompts, multi-turn chat, agents
A prefix-cache hit skips prefill for the shared tokens entirely, so cache-aware routing moves TTFT and GPU cost at once. Spreading the same traffic round-robin across N replicas divides your hit rate by roughly N for any prefix that is not already warm everywhere.
The failure mode of cache-aware routing is the mirror image of round-robin's: affinity concentrates load. One tenant's popular system prompt hashes to one replica and that replica tips into preemption while the fleet idles. The working design is affinity with a load cap. Prefer the replica holding the prefix unless its queue time exceeds a threshold, then spill to the least-loaded replica and accept the cache miss. Measure it by prefix-cache hit rate per replica alongside queue time. A rising hit rate with a flat or falling p99 TTFT means the policy is working. A rising hit rate with a rising p99 means you are herding.
Put a number on the prize before building it. In an agent loop where each call carries ~20k tokens of accumulated context and adds ~1k, a warm prefix turns a 21k-token prefill into a 1k-token one. At the illustrative 0.07 ms per prefill token from 2.3, that is roughly 1.4 s of GPU time and TTFT saved per call, on every call after the first. Across N replicas with no affinity the hit probability for a given conversation is about 1/N, so on an 8-replica pool the router alone decides whether that saving happens ~12% or ~90%+ of the time. Few server-side tunings are worth that much.
Two habits inherited from stateless RPC load balancing are actively harmful here. Hedged requests, sending a duplicate to a second replica when the first is slow, are cheap insurance when a request costs microseconds of CPU; for an LLM call the duplicate costs a full prefill plus decode, lands during exactly the congestion that made the first one slow, and must be cancelled on the loser, which is the disconnect propagation from 2.1 again. Hedge only on TTFT for short prompts, if at all. Health checks that test liveness are the other. A replica that answers /health in 2 ms while its KV is saturated and preemptions are climbing is alive and useless; the router needs readiness defined as "can take a request and meet the SLO", exported by the engine as queue time and KV headroom, and it should stop sending a replica traffic before it starts preempting, not after it stops answering.
Everything in this chapter serves one contract: the serving SLO, expressed as three numbers held together — TTFT (how fast the first token appears), tokens per second (how fast the answer streams), and availability (how often you honor both). You size replicas to your peak load, not your average, then defend the SLO with the levers stacked through the chapter: a bounded queue with admission control so overload sheds instead of melting, chunked prefill so long prompts do not spike the tail, batch size tuned against the KV ceiling for utilization, queue-depth autoscaling with warm headroom for demand swings, and a right-sized model fleet so you are never paying for a 70B GPU to do an 8B job.
State the SLO as goodput: the share of requests that met both the TTFT and the inter-token target, measured per traffic class. Averages hide the failure this chapter keeps returning to. A fleet where 90% of requests stream at 80 tok/s and 10% sit in a preemption loop reports a healthy mean and a tolerable p50 while a tenth of users watch a frozen cursor. Goodput counts those as failures, and it is the one number that falls in every cascade described here: KV exhaustion, prefill stalls, cold replicas, thrash and herding. Make it the primary alert, and use queue time, preemption rate, swap-ins and prefix hit rate to explain it.
TTFT
First-token SLO
Queue time
Scale signal
KV cache
Concurrency cap
Cold start
Minutes, not ms
Questions to ask in a design review
Where next