Skip to content

Cold Starts and Scaling Jitter: Find the Stuck Layer Before Adding Replicas

The worst thing during a traffic spike is not slowness - it is "adding replicas makes it worse." A new pod is still pulling weights while the HPA has already launched another wave; or a replica is up but never receives traffic because its readiness probe never passed. The first move in a cold-start problem is to locate the bottleneck, not to scale.

This article organizes the problem by four causes: slow model loading / misconfigured readiness probes / HPA flapping / GPU memory fragmentation. Commands follow the vLLM official docs and the Kubernetes HPA official docs.

Classification: find which layer the replica is stuck in

Symptom -> check -> conclusion -> action

Pod Running but 503 / no traffic
  |-- check kubectl logs (weight loading progress) + /health result
  `-- conclusion: slow load or bad readiness probe -> fix initialDelay, read load logs

Traffic up but replica count unchanged
  |-- check kubectl get hpa TARGET column + describe hpa Conditions
  `-- conclusion: HPA has no metrics or not-ready pod metrics set aside -> fix metrics first

Replicas jumping between 1 and N
  |-- check HPA events + scale-down window + new replica readiness time
  `-- conclusion: flapping -> lengthen stabilization window + remove cold-start metric spikes

Node has free memory but new instance OOMs
  |-- check nvidia-smi per-card usage + gpu_cache_usage_perc
  `-- conclusion: fragmentation or cache pool full -> lower memory use / change dtype / pin GPU

The three signal sources differ: loading/probes come from container logs and /health; HPA comes from kubectl get hpa metrics and describe hpa conditions; memory comes from nvidia-smi and vLLM metrics. Put all three on one dashboard and classify before acting.

Branch One: Slow Model Loading and Readiness Probes

A vLLM instance goes from start to ready through weight download/deserialization, KV cache initialization, and possibly CUDA graph capture on first run - tens of seconds to minutes. The container is Running throughout, but /health will not pass until loading finishes. A readiness probe with /health and a sufficient initialDelaySeconds keeps traffic away until then; without it, you either send traffic to an unready instance or keep a ready instance out of the backend.

Knobs that shorten loading time (see official docs):

vllm serve <model> --load-format safetensors --dtype auto
  • --load-format safetensors: skips format detection and loads safetensors explicitly; with weights already in the local cache it also avoids repeated downloads.
  • --dtype auto: picks precision from the model config, avoiding an accidental FP32 selection that doubles memory use and load time.

If cold start is extremely sensitive, --enforce-eager skips CUDA graph capture and torch.compile for a faster startup, but degrades steady-state throughput and latency (the docs explicitly state it disables both). Treat it as a trade-off or a debugging control, not a production default. Another approach is to pre-warm weights into the image or a local cache (--download-dir pointing at the pre-warmed directory), moving "download" off the cold-start path entirely.

Branch Two: A Stuck HPA and Flapping

The Kubernetes HPA is an intermittent control loop (15-second default sync period), not a continuous process. Two official facts explain "no scale-up during a spike":

  1. Metrics from not-yet-ready pods are set aside: per the official algorithm, a pod with missing metrics or one that is not yet ready has its metrics set aside, making the scale-up decision more conservative - a cold-starting replica holds back the HPA.
  2. Initial readiness delay: the window in which a pod is considered "first ready" is configurable via --horizontal-pod-autoscaler-initial-readiness-delay (default 30 seconds); rapid Ready/Unready transitions inside that window have their metrics ignored.

Diagnostic commands (both appear in the official HPA walkthrough):

kubectl get hpa <name> --watch
kubectl describe hpa <name>

The Conditions in describe (AbleToScale / ScalingActive / ScalingLimited) tell you directly whether the HPA cannot obtain metrics or is constrained by min/max replicas.

For replica-count flapping: the official scale-down stabilization window defaults to 5 minutes (--horizontal-pod-autoscaler-downscale-stabilization), precisely so brief metric spikes do not trigger a scale-down. If that is not enough, set separate behavior.scaleDown.stabilizationWindowSeconds and behavior.scaleUp.stabilizationWindowSeconds in an autoscaling/v2 HPA. Note that this only suppresses the symptom; if the root cause is inflated metrics from cold-starting replicas, fix the probe and load time first.

Branch Three: Memory Fragmentation and a Full Cache Pool

"A second instance will not start although the node has free memory" usually means contiguous free memory, not total. KV cache preallocation and multi-process colocation create fragmentation. Check per-card usage and the cache watermark:

nvidia-smi --query-gpu=index,memory.used,memory.total --format=csv
curl -s http://localhost:8000/metrics | grep -E "gpu_cache_usage_perc"
  • gpu_cache_usage_perc close to 1: the KV cache pool is full and concurrency is at its ceiling. Before adding an instance, lower that instance's gpu-memory-utilization or switch to --kv-cache-dtype fp8 to reduce per-token memory.
  • Enough total memory but no contiguous block: pin instances to different GPUs so fragmentation does not stack, and evict other processes using memory if needed.
  • Physically insufficient memory: adding a GPU is more direct than further tuning.

Three Failure Cases (Built from Typical Production Scenarios)

Case 1: traffic was routed to a pod as soon as it was Running, causing a wave of 503s. A team saw all pods Running in kubectl get pods after a scale-up and added the new replicas to the load balancer; users got 503s. Logs showed weights still loading and /health never passing. The root cause was an over-aggressive readiness probe (initialDelay too short). The fix was to set initialDelaySeconds from measured load time and gate traffic on /health. Lesson: Running does not mean ready; the readiness probe is the last gate during a cold start.

Case 2: the HPA would not scale during a spike, then scaled and immediately shrank. An online service kept its replica count flat at peak, then jumped from 1 to 8, then back to 1 minutes later. describe hpa showed ScalingActive=False (metrics pipeline down); meanwhile not-yet-ready replicas had their CPU metrics set aside and the scale-down window was too short. The fix was to repair Metrics Server/custom metrics so the HPA had data, lengthen the scale-down window, and use behavior to set separate up/down windows. Lesson: if the HPA will not scale, check the metrics pipeline; if it flaps, check the stabilization window - do not rush to change thresholds.

Case 3: a second instance OOMed despite 8 GB showing free on the node. One instance was already on a card, monitoring showed 8 GB free, but starting a second instance OOMed. The root cause was no contiguous block after KV cache preallocation, plus the first instance's cache pool consuming allocatable memory. The fix was to pin the second instance to another GPU and lower the first instance's gpu-memory-utilization from 0.95 to 0.9. Lesson: memory is about contiguous blocks, not totals; the cache watermark is more honest than nvidia-smi's free figure.

Quick Reference

Symptom Check first Likely cause Action
Running but 503 /health + load logs still loading / probe too eager fix initialDelay, wait for /health
No scale-up at peak get hpa TARGET + describe Conditions no metrics / not-ready metrics set aside fix Metrics Server + read scaling conditions
Replicas keep jumping HPA events + stabilization window flapping lengthen scale-down window + set behavior
Free memory but OOM nvidia-smi + gpu_cache_usage_perc fragmentation / full cache pool lower memory use / change dtype / pin GPU
Very slow startup load logs weight download / CUDA graph capture pre-warm weights + consider --enforce-eager trade-off

Originality statement: All decision frameworks, commands and cases in this article were assembled by the author from the vLLM official docs and the Kubernetes HPA official docs together with hands-on production troubleshooting; the three cases are built from typical production scenarios and are not records of any specific customer site.