At cluster scale, the expensive thing is rarely arithmetic; it is moving bytes. Prompts that are recomputed because they landed on the wrong replica, KV caches that cross a slow link, weights that take minutes to load, and model shards placed across racks all burn time and money. This lesson turns that into design rules: route requests to where their data already is, tier the KV cache, place model replicas to match the network topology, and use Kubernetes building blocks made for inference rather than generic load balancing.
- Explain why round-robin load balancing wastes work for LLM traffic
- Design KV-aware and session-aware routing with an inference gateway
- Use a KV-cache hierarchy from GPU memory to remote storage
- Place multi-GPU replicas to match NVLink domains, racks and nodes
- Draw a data-movement budget for a request and find the dominant transfer
Route to where the data already is
A web load balancer spreads requests evenly and assumes any replica is as good as another. For LLMs that assumption is wrong: a replica that already holds a conversation's history or a shared system prompt in its KV cache can skip most of the prefill. Round-robin destroys that locality, so every replica keeps recomputing the same prefixes.
- Session affinity sends a conversation's turns to the same replica. Simple, but it ignores load and breaks when the replica is busy or gone.
- KV-aware routing hashes prompt prefixes into blocks, tracks which replica holds which blocks, and scores replicas by cache overlap and current load. Dynamo's router and the llm-d inference scheduler do this.
- Load- and queue-aware routing uses each replica's waiting requests and cache usage, which the engines expose as metrics, to avoid hot spots even without cache overlap.
- Adapter-aware routing sends requests for a LoRA adapter to replicas that already have it loaded.
On Kubernetes, the Gateway API Inference Extension standardises this: an InferencePool groups the model-server pods, and an endpoint picker called by the gateway (through Envoy's external processing) chooses the best pod per request using engine metrics such as queue length and prefix-cache state.
apiVersion: inference.networking.k8s.io/v1
kind: InferencePool
metadata:
name: chat-pool
spec:
selector:
matchLabels:
app: vllm-chat
targetPorts:
- number: 8000
endpointPickerRef:
name: chat-epp
port:
number: 9002
failureMode: FailOpenTier the KV cache
GPU memory is the fastest and smallest place for KV cache. When it is full, the choice is to evict and later recompute (spending GPU time) or to move blocks to a cheaper tier and bring them back (spending bandwidth). For long, idle conversations and shared documents, keeping cache is usually cheaper than recomputing it.
| Tier | Capacity | Reach | Good for |
|---|---|---|---|
| GPU HBM | Smallest | Fastest | Active sequences |
| CPU DRAM | Several times larger | Over PCIe | Recently idle conversations |
| Local NVMe | Much larger | Slower, still local | Long-lived prefixes on this node |
| Shared or object storage | Effectively unlimited | Over the network | Cache shared across nodes, warm restarts |
Tools such as Dynamo's KV Block Manager, LMCache and vLLM's offloading connector implement these tiers. Combined with KV-aware routing, a cluster can behave like one large cache: a request goes where its prefix is, and if no GPU has it, a node can fetch it from a lower tier instead of recomputing.
Place replicas to match the topology
- Keep each tensor-parallel group inside one NVLink domain: one node, or a rack-scale NVLink system.
- Place pipeline stages and disaggregated prefill/decode pairs on nodes with fast RDMA paths between them, ideally the same rack or network spine.
- Schedule multi-pod replicas as a unit: all pods start together or none do. LeaderWorkerSet in Kubernetes deploys a group of pods as one unit of replication; topology-aware gang schedulers such as Grove add rack and NVLink-domain placement.
- Spread whole replicas across failure domains for availability, but never split one replica across them.
- Keep weights close to the GPUs (node-local caches, pre-pulled images) so scaling out does not wait on downloads.
A data-movement budget
For any design, list every transfer a request causes, its size and the link it uses, and estimate its time. The largest line is where to spend design effort.
| Transfer | Typical size | Link |
|---|---|---|
| Prompt and response text | Kilobytes | Client network |
| TP all-reduces per decode step | Hundreds of KiB, many times per step | NVLink |
| KV handoff (disaggregated) | Hundreds of MiB per long prompt | RDMA or NVLink |
| KV fetch from lower tier | Up to the size of the prefix | PCIe, NVMe or network |
| Weights on scale-out | Tens to hundreds of GB per replica | Storage and PCIe |
Draw the budget before choosing tools. Teams often adopt disaggregation or cache offload when their dominant cost was actually cold-start weight loading or a gateway that ignores cache locality.