Skip to main content
AI on Kubernetes · GPU/NPULesson 14 of 20

Which Replica Gets the Request (Inference Routing)

When one model runs as several replicas, every request needs a target replica. Round-robin is enough for a typical web service, but LLM requests vary hugely in length, and each replica holds a different already-computed prefix (prefix cache). So an endpoint picker (EPP) sits behind the gateway and chooses a replica by looking at replica state.

Requested model—
Chosen replicaReplica 3
Whyturn order
Replicas of one modelApplicationOpenAI-compatibleGatewayauth · limits · modelPicker (EPP)chooses replicaReplica 1idleReplica 2has same prefixReplica 3busy on long inputlong queueits turn
RequestResponse / reportWatchAppears in a later step

What you will learn

  • Why round-robin does not fit LLMs
  • The gateway picks the model; the EPP picks the replica
  • Routing by prefix cache speeds up the first token
  • Load must count too, or traffic piles onto one replica

On Kubernetes​

In the Gateway API Inference Extension, the replicas of one model are defined as an InferencePool (inference.networking.k8s.io/v1), and the endpoint picker (EPP) attached to it chooses a replica per request. The gateway is any implementation that supports the extension. Projects such as llm-d add prefix-cache and load-based scoring on top, and for prefill/decode disaggregated serving they choose a prefill replica and a decode replica together. For what the prefix cache is, see How the KV Cache Fills Up; for split serving, see Splitting Prefill and Decode (P/D Disaggregation).

Try it yourself​

kubectl get inferencepools -A # Replica set per model (InferencePool)
kubectl describe inferencepool <name> -n <namespace> # Pod selector and the attached EPP
kubectl get httproutes -n <namespace> # Gateway route pointing at the pool
curl -s http://<engine>:8000/metrics | grep -E 'vllm:(num_requests_waiting|kv_cache_usage_perc|gpu_cache_usage_perc)' # e.g. vLLM: load the picker scores (step 4)
curl -s http://<engine>:8000/metrics | grep vllm:prefix_cache # Prefix cache queries and hits per replica (step 5)

Check yourself

  1. In inference routing, which component decides which replica a request goes to?
  2. Requests that share a system prompt all go to replica 2 because it has the prefix cached. Its queue grows while replicas 1 and 3 sit idle. What should the picker do?
  3. You added replicas, but the first token is not getting faster. What should you check first?

Further reading: Gateway API Inference Extension · llm-d · vLLM docs