Inference-Aware Load Balancing for LLMs (part 9): autoscaling model servers on the right signal

Why CPU is the wrong signal for a model server; KEDA and Prometheus scaling vLLM on requests running and waiting, configured on camera; one replica against two, the cold start measured, and scaling back in.
Hand-drawn: time to first token from 1.45 s to 0.07 s with a second replica, and 81 s to Ready with 10 s cold first tokens

On this page

Eight clients against one replica that runs four sequences at a time: 28 answers every 10 seconds and 1.45 s to the first token. KEDA, reading what the model server is full of from Prometheus, asked for a second replica within 30 seconds; it was Ready 81 seconds after the load began, and then 41 to 45 answers every 10 seconds at 0.07 s to the first token. This is part 9 of Inference-Aware Load Balancing for LLMs: autoscaling a model server on the right signal, configured on camera, the cold start measured, and scaling back in. This post goes with a video on the LevelUP I.T. YouTube channel.

One replica against two, every 10 seconds
One replica against two, every 10 seconds

Why CPU is the wrong signal

A vLLM replica on CPU runs its threads flat out whenever it has work, one request or forty; its CPU says busy, never how busy, and GPU utilisation says as little. What fills up is the batch: requests running, requests waiting, and the KV cache. A full replica shows it as requests waiting, and as time to first token growing with them. So scale on the server's own gauges, vllm:num_requests_running + vllm:num_requests_waiting (or KV-cache use, or a latency target).

The signal's source: Prometheus

helm install prometheus /stage/charts/prometheus-29.47.0.tgz -n monitoring --create-namespace -f /k8s/inference/prometheus-values.yaml --wait

alertmanager: {enabled: false}
kube-state-metrics: {enabled: false}
prometheus-node-exporter: {enabled: false}
prometheus-pushgateway: {enabled: false}
server: {persistentVolume: {enabled: false}, retention: 6h, global: {scrape_interval: 5s, scrape_timeout: 4s, evaluation_interval: 5s}}

The chart's default 10 s scrape timeout fails validation at a 5 s interval, hence 4 s. Prometheus finds the vLLM pods by the annotations the generated Deployment has carried since part 2 (prometheus.io/scrape: "true", port 8000, path /metrics), so each replica's gauges arrive with its pod and model name; a small helper, promq.py, queries them from the client pod.

The autoscaler: KEDA

The Horizontal Pod Autoscaler cannot read a Prometheus query; KEDA 2.21.0's operator watches ScaledObjects, its metrics server answers the HPA by running the query, and it creates and owns the HPA (keda-hpa-lfm-1-2b). The generated values set only image: {pullPolicy: IfNotPresent}: the chart's Always fails in an offline lab even with the image on the node.

This post is for paying subscribers only

Subscribe to LevelUp I.T. newsletter and stay updated.

Don't miss anything. Get all the latest posts delivered straight to your inbox. It's free!
Great! Check your inbox and click the link to confirm your subscription.
Error! Please enter a valid email address!