Round-Robin Is Wasting Your GPUs: LLM-Aware Load Balancing on Kubernetes

Contents
Sam Altman on X: “it’s super fun seeing people love images in chatgpt. but our GPUs are melting.”
Sam Altman on X, March 27, 2025 (original post)

OpenAI’s GPUs melted from too much demand. Yours might be melting from bad routing.

You deploy vLLM with three replicas, put a Kubernetes Service in front, and send real traffic. Then you open the dashboard:

“One GPU is at 100% with a queue of requests. The other two are idle. Why?”

Sketch: kube-proxy sends a 5-token “hi” and a 30,000-token PDF one per GPU. GPU 0 is on fire with 37 requests waiting, GPU 1 and 2 are asleep
Round-robin vs. LLM traffic

The problem#

A Service does round-robin. That works for web traffic, where every request costs about the same. LLM traffic breaks that assumption twice:

  • Requests aren’t equal. A 5-token “hi” takes milliseconds. A 30,000-token PDF keeps a GPU busy for seconds. Round-robin counts both as “one request”.
  • Replicas aren’t equal. vLLM caches prompts it has already processed (the prefix cache). Send a repeated system prompt to the replica that has it cached, and most of the work is skipped. Send it anywhere else, and the GPU computes it all over again.

“So my GPUs are busy, but doing the wrong work in the wrong place.”

GPUs are the most expensive thing in your cluster, so that waste is real money. The fix is a load balancer that looks inside each model server before it picks one.

30-second vocabulary#

TermWhat it is
ModelA file of weights (Qwen, Llama). It does nothing on its own.
vLLMThe server that loads the model onto a GPU and answers OpenAI-style HTTP requests. One vLLM = one pod. It publishes metrics like queue length and KV-cache usage.
llm-dAn open-source project for running vLLM at scale on Kubernetes. This post uses two of its pieces: the router (EPP) and a vLLM simulator.
InferencePoolA backend for an HTTPRoute that replaces the Service: “these model server pods, plus the picker that chooses between them”. From the Gateway API Inference Extension.
Endpoint Picker (EPP)The picker, from the llm-d router. A small CPU pod that reads every vLLM pod’s metrics and chooses the best pod for each request.
GatewayTakes the traffic, asks the EPP which pod to use (over Envoy’s ext-proc protocol), then forwards. I use agentgateway.
Inference gateway architecture
Fig. 1: a request goes to the gateway, the gateway asks the EPP which pod to use, then the gateway sends the request to that pod

What you need#

Docker, kind, kubectl and Helm v3.8+. About 2 CPUs and 3 GB of free memory.

ComponentVersion
Gateway API CRDsv1.7.0
Gateway API Inference Extension (InferencePool CRD)v1.6.2
agentgatewayv1.7.0
llm-d router (EPP)v1.0.0
llm-d-inference-simv1.2.0

Step 1: Cluster and CRDs#

kind create cluster --name llm-inference

# Gateway API
kubectl apply --server-side -f \
  https://github.com/kubernetes-sigs/gateway-api/releases/download/v1.7.0/standard-install.yaml

# InferencePool
kubectl apply -f \
  https://github.com/kubernetes-sigs/gateway-api-inference-extension/releases/download/v1.6.2/manifests.yaml

Step 2: Install the gateway#

helm upgrade -i agentgateway-crds oci://cr.agentgateway.dev/charts/agentgateway-crds \
  --version v1.7.0 -n agentgateway-system --create-namespace

helm upgrade -i agentgateway oci://cr.agentgateway.dev/charts/agentgateway \
  --version v1.7.0 -n agentgateway-system \
  --set inferenceExtension.enabled=true --wait

inferenceExtension.enabled=true lets agentgateway route to an InferencePool.

k9s showing the agentgateway pod Running in agentgateway-system
Fig. 2: the agentgateway controller is up

Step 3: Three “vLLM” replicas#

cat << EOF | kubectl apply -f -
apiVersion: apps/v1
kind: Deployment
metadata:
  name: qwen
spec:
  replicas: 3
  selector:
    matchLabels:
      app: qwen
  template:
    metadata:
      labels:
        app: qwen
    spec:
      containers:
      - name: vllm
        image: ghcr.io/llm-d/llm-d-inference-sim:v1.2.0   # fake vLLM: same API + metrics, no GPU
        args:
        - --model=demo/qwen3-0.6b        # made-up name: no tokenizer download
        - --port=8000
        - --max-num-seqs=4               # each replica runs 4 requests at once
        - --time-to-first-token=200ms
        - --inter-token-latency=30ms
        - --time-factor-under-load=2.0   # gets slower as it fills up, like a real GPU
        env:
        - name: POD_NAME
          valueFrom: {fieldRef: {fieldPath: metadata.name}}
        - name: POD_NAMESPACE
          valueFrom: {fieldRef: {fieldPath: metadata.namespace}}
        - name: POD_IP
          valueFrom: {fieldRef: {fieldPath: status.podIP}}
        ports:
        - containerPort: 8000
          name: http
        readinessProbe:
          httpGet: {path: /health, port: 8000}
        resources:
          requests: {cpu: 50m, memory: 64Mi}
EOF

kubectl rollout status deploy/qwen

There’s no Service. The InferencePool selects these pods directly.

k9s showing three qwen pods Running
Fig. 3: three model server replicas

Step 4: The InferencePool and its Endpoint Picker#

One Helm chart creates both:

helm install qwen oci://ghcr.io/llm-d/charts/llm-d-router-gateway \
  --version v1.0.0 \
  --set router.modelServers.matchLabels.app=qwen

kubectl rollout status deploy/qwen-epp
k9s showing the three qwen pods plus the qwen-epp pod
Fig. 4: the EPP (qwen-epp) runs next to the model servers, on CPU

The pool it creates is short. It selects the pods by label and names the EPP that picks between them:

apiVersion: inference.networking.k8s.io/v1
kind: InferencePool
metadata:
  name: qwen
spec:
  selector:
    matchLabels:
      app: qwen
  targetPorts:
  - number: 8000
  endpointPickerRef:
    name: qwen-epp
    port:
      number: 9002
k9s listing the qwen InferencePool
Fig. 5: kubectl get inferencepool

For every request, the EPP scores each pod and the highest total wins:

  • queue-scorer (weight 2): prefers the pod with the shortest queue
  • kv-cache-utilization-scorer (weight 2): prefers the pod with the most free KV cache
  • prefix-cache-scorer (weight 3): prefers the pod that already has this prompt cached
EPP config in k9s showing the default scheduling profile with the three scorers and their weights
Fig. 6: the EPP’s default scheduling profile (kubectl get cm -l app.kubernetes.io/name=qwen-epp -o yaml)

Step 5: Gateway and route#

cat << EOF | kubectl apply -f -
apiVersion: gateway.networking.k8s.io/v1
kind: Gateway
metadata:
  name: inference-gateway
spec:
  gatewayClassName: agentgateway
  listeners:
  - name: http
    protocol: HTTP
    port: 80
---
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
  name: qwen
spec:
  parentRefs:
  - name: inference-gateway
  rules:
  - matches:
    - path: {type: PathPrefix, value: /}
    backendRefs:
    - group: inference.networking.k8s.io
      kind: InferencePool         # not a Service
      name: qwen
    timeouts:
      request: 300s               # LLM responses take a while
EOF

kubectl wait --for=condition=Programmed gateway/inference-gateway --timeout=120s
kubectl get httproute qwen -o jsonpath='{.status.parents[0].conditions[*].type}{"\n"}'
# Accepted ResolvedRefs

The only real change from a normal web app is backendRefs: it points at the InferencePool instead of a Service.

Step 6: Send a request#

Forward the gateway’s Service:

kubectl port-forward svc/inference-gateway 8080:80

In another terminal, define a small helper first. served prints how many requests each replica has completed, read from each pod’s /metrics. The tests below use it:

served() {
  for p in $(kubectl get pods -l app=qwen -o jsonpath='{.items[*].metadata.name}'); do
    n=$(kubectl get --raw "/api/v1/namespaces/default/pods/$p:8000/proxy/metrics" \
        | awk '/^vllm:request_success_total/ {s+=$2} END {print s+0}')
    echo "$p  $n"
  done
}

served

Nothing has been sent yet, so every pod is at zero:

served output: all three qwen pods at 0 requests
Fig. 7: no requests yet

Now send one request through the gateway, then check again:

curl -s localhost:8080/v1/chat/completions \
  -H 'Content-Type: application/json' \
  -d '{
    "model": "demo/qwen3-0.6b",
    "messages": [{"role": "user", "content": "Explain Kubernetes in one sentence."}],
    "max_tokens": 30
  }' | jq '{model, text: .choices[0].message.content, usage}'

served
curl returning an OpenAI-style JSON response, then served showing one pod at 1
Fig. 8: the simulator’s answer is filler, but the gateway asked the EPP and sent the request to one pod

One pod now shows 1. The request went through the gateway, the EPP picked a pod, and that pod answered.

Step 7: Watch the picker work#

Same prompt, same pod#

Send one long prompt ten times:

PROMPT="You are a support bot for ACME Cloud. $(printf 'Policy line %s. ' $(seq 1 200)) Question: how do I reset my password?"

for i in $(seq 1 10); do
  curl -s -o /dev/null localhost:8080/v1/chat/completions \
    -H 'Content-Type: application/json' \
    -d "$(jq -n --arg p "$PROMPT" '{model:"demo/qwen3-0.6b",messages:[{role:"user",content:$p}],max_tokens:20}')"
done
served
served output: all 10 repeated prompts landed on one pod
Fig. 9: all ten went to the same pod. The prefix-cache-scorer at work

All ten land on one pod. With a real model, that’s GPU time you don’t pay for twice.

The same test through a plain Service#

“Would a normal Service really do worse?” Let’s check. Put a Service in front of the same three pods:

cat << EOF | kubectl apply -f -
apiVersion: v1
kind: Service
metadata:
  name: qwen-svc
spec:
  selector:
    app: qwen
  ports:
  - port: 8000
    targetPort: 8000
EOF

Send the requests from a pod inside the cluster, so they go through kube-proxy like real traffic. (kubectl port-forward would pin everything to one pod.) The output shows how much each pod’s count went up:

PROMPT="You are a support bot for ACME Cloud. $(printf 'Policy line %s. ' $(seq 1 200)) Question: how do I reset my password?"
BODY=$(jq -cn --arg p "$PROMPT" '{model:"demo/qwen3-0.6b",messages:[{role:"user",content:$p}],max_tokens:20}')

before=$(served)
kubectl run svc-test -q --rm -i --restart=Never --image=curlimages/curl:8.11.1 \
  --env="BODY=$BODY" --command -- sh -c '
    for i in $(seq 1 10); do
      curl -s -o /dev/null http://qwen-svc:8000/v1/chat/completions \
        -H "Content-Type: application/json" -d "$BODY"
    done'
paste <(echo "$before") <(served) | awk '{print $1, "+" $4-$2}'
served output after the Service test: +2, +4 and +4 across the three pods
Fig. 10: the same ten prompts through a plain Service

The same ten prompts now spread across all three pods. kube-proxy doesn’t look at the request, so it can’t know which pod has the prompt cached. Three pods compute it from scratch instead of one.

Heavy load, no hot spots#

Now 60 different prompts, 12 at a time. That’s more than the 3 × 4 slots the replicas have:

seq 1 60 | xargs -P 12 -I{} curl -s -o /dev/null localhost:8080/v1/chat/completions \
  -H 'Content-Type: application/json' \
  -d '{"model":"demo/qwen3-0.6b","messages":[{"role":"user","content":"Request {}: write a haiku about pods"}],"max_tokens":40}'
served
Fig. 11: left, the load test (counts are cumulative across runs). Top right, gateway logs: selected_endpoint changes from request to request. Bottom, the EPP handling each request.

When a replica starts to queue, its queue-scorer and kv-cache-utilization-scorer scores drop and new requests go elsewhere. The counts stay close, and no replica builds a backlog while another sits idle. To see each decision yourself:

kubectl logs deploy/qwen-epp --tail=50

Moving to real GPUs#

Swap the simulator for real vLLM and request a GPU. Nothing else changes:

      containers:
      - name: vllm
        image: vllm/vllm-openai:<version>
        args: ["--model=Qwen/Qwen3-0.6B", "--port=8000"]
        resources:
          limits:
            nvidia.com/gpu: 1

The EPP reads the same vllm:* metrics, so the pool, route and gateway stay as they are. To share one GPU between pods, combine this with Kubernetes DRA, or HAMi / Run:ai from my multi-tenant GPU posts.

Where to go next#

  • InferenceObjective: give interactive chat priority over batch jobs when the pool is busy.
  • Several models on one gateway: one InferencePool and one HTTPRoute rule per model.
  • Prefill/decode disaggregation: llm-d can run prompt processing and token generation on different pods.

Clean up#

kind delete cluster --name llm-inference

Wrap-up#

“Why is one GPU on fire while the others sleep?” Because a Service counts connections, not work. Keep Gateway API, put an InferencePool behind the route, and let the Endpoint Picker choose pods from live vLLM metrics. With the simulator, you can try it all on a laptop in about ten minutes.

References#

Comments

Sign in with GitHub to react or leave a comment.

← All posts