Mental model
Autoscaling adds GPU replicas over minutes while multi-gigabyte model weights load into VRAM, whereas backpressure protects active replicas within milliseconds. Bounding admitted concurrency via Little's Law, autoscaling on KV-block utilization and waiting queues rather than CPU, and shedding excess load via AIMD prevents cascading timeout and retry collapse.
Learning outcomes
- Apply Little's Law () to distinguish queueing delay from prefill and decode execution latency in LLM serving.
- Replace broken CPU utilization autoscaling triggers with KV-cache block utilization, waiting queue depth, and preemption metrics.
- Bridge multi-minute GPU container cold starts using AIMD concurrency limits, retry budgets, and jittered
HTTP 429shedding. - Propagate request deadlines and configure Kubernetes readiness gates plus graceful pod termination drains to avoid orphaned decode streams.
Theory
Horizontal Pod Autoscaling (HPA) in stateless microservices reacts within seconds because containers start rapidly and CPU utilization tracks saturation. LLM serving violates both assumptions. Loading a 70B BF16 model across tensor-parallel GPUs takes two to six minutes for image pull, weight deserialization, NCCL setup, and CUDA graph capture. Meanwhile, host CPU utilization frequently stays under 25% even when GPU HBM bandwidth or KV-cache blocks reach 99% exhaustion.
Saturation starts with Little's Law, linking average active requests , arrival rate , and mean residence time :
For autoregressive generation, total latency decomposes into scheduler wait time , compute-bound prefill duration (determining Time To First Token, ), and bandwidth-bound decode steps over output tokens at Inter-Token Latency ( or ):
When arrival rate exceeds completion rate , active concurrency climbs until physical KV blocks fill. In vLLM V1 (vllm/v1/core/sched/scheduler.py), exhausting free KV blocks forces sequence preemption—evicting or recomputing running requests—spiking TTFT and TPOT across co-scheduled streams. Unbounded queues inflate until clients time out, fire retries, and multiply against a saturated cluster.
To preserve latency inside SLOs while Kubernetes HPA provisions replicas, gateways enforce Additive Increase, Multiplicative Decrease (AIMD) concurrency control (following Google SRE overload patterns):
Excess traffic past receives HTTP 429 with jittered Retry-After headers and strict client retry budgets (e.g., capping retries at 10% of volume). Simultaneously, HPA scales on engine custom metrics—KV-block saturation (kv_cache_usage_perc), waiting queue depth, and num_preemptions_total—paired with slow scale-down stabilization (5–10 minutes) and terminationGracePeriodSeconds long enough to drain active SSE streams before SIGKILL.
Worked quantitative example
Consider one GPU replica sustaining at mean duration . By Little's Law, steady concurrency is active sequences at 85% KV-block usage. Suppose traffic triples to for 180 s while new pods need 210 s to warm weights.
With an unbounded queue, backlog grows at , accumulating 2,880 queued requests in 180 s. The tail request waits —far past a 15 s client timeout—causing retries that drive effective above 40 req/s while replicas burn cycles decoding abandoned sockets.
With AIMD backpressure (c_min = 8, c_max = 32, alpha = 1, beta = 0.7), once KV usage hits 90% and TTFT passes 900 ms, AIMD cuts concurrency from 28 to 19 (floor(28 * 0.7)). Admitted requests hold < 900 ms TTFT and smooth ITL, while excess 16 req/s fail fast in < 2 ms with 429 + jitter until newly scaled GPU pods pass readiness probes at 210 s.
Autoscaling and backpressure signal comparison
| Signal / Mechanism | Reaction Horizon | Failure Mode When Used Alone | Production Role |
|---|---|---|---|
| Host CPU Utilization | 30–60 s | Blind to GPU VRAM and KV pressure | Never use as primary LLM HPA metric |
| Raw GPU SM Utilization | 15–30 s | Reads high in prefill, lower in decode | Diagnostic telemetry only |
| KV-Cache Utilization + Waiting Queue | 15–60 s | Too slow for sudden 3x traffic spikes | Primary HPA custom scale-out trigger |
| AIMD Concurrency Gate + Bounded Queue | < 5 ms | Sheds demand rather than adding capacity | Immediate shield during cold starts |
Trade-offs
Aggressive scale-up policies with short stabilization windows protect headroom during sustained demand ramps, yet brief spikes trigger expensive multi-minute model loads and scale-down churn if cooldown windows stay tight. Keeping warm standby replicas absorbs bursts smoothly at the cost of persistent idle GPU spend.
Tight concurrency caps and sharp multiplicative backoff (beta = 0.5) protect interactive P99 TTFT rigorously, though they reject borderline bursts slightly earlier than larger queues. Partitioning priority tiers—shedding offline batch summarization jobs before interactive chat streams—protects user-facing SLOs without over-provisioning for peak batch arrivals.
Failure modes and misconceptions
- Scaling GPU replicas on Kubernetes CPU utilization. Decode throughput bottlenecks on HBM bandwidth and KV blocks, leaving CPU cores largely idle while TTFT degrades into tens of seconds.
- Allowing unbounded ingress queues ahead of vLLM. Queuing requests past client timeouts converts overload into universal collapse: every request times out, retries fire simultaneously, and zero callers finish.
- Dropping client streams without propagating cancellation. If an ingress proxy disconnects without forwarding
AbortSignalor gRPC deadline cancellation, GPUs keep decoding wasted tokens and pinning KV blocks. - Counting unready pods or lacking scale-down drains. Readiness probes must gate traffic until weight loading and CUDA graphs finish, while
preStopdrains andterminationGracePeriodSecondspreserve live SSE streams during scale-in. - Synchronized client retries without jitter. Immediate retries on
503or429create self-inflicted thundering herds that block AIMD recovery.
Decision scenario
An interactive chat service runs on 4 GPU pods sustaining 32 req/s combined (8 req/s each) at 82% KV saturation. At 09:00 UTC, arrival rate jumps to 96 req/s in 30 seconds while new GPU replicas need 4 minutes to load weights.
Configure deadline propagation (request_timeout = 12s), priority admission shedding batch workloads first, and an AIMD concurrency limiter triggered by KV utilization (> 0.85) and TTFT P95 (> 850ms) returning HTTP 429 with jittered Retry-After. Drive Kubernetes HPA from kv_cache_usage_perc > 0.70 and num_requests_waiting, keep scaleDown stabilization at 600s, gate readiness on initialized CUDA graphs, and add a preStop drain hook.
Implementation example
This Python AIMD concurrency controller and deadline-aware admission gate shrinks active concurrency multiplicatively when KV saturation or TTFT breaches SLO bounds and sheds stale or excess requests immediately.
pythonfrom dataclasses import dataclassimport mathimport time@dataclassclass ReplicaHealth:kv_cache_ratio: floatttft_p95_ms: floatwaiting_requests: intclass AimdInferenceGate:def __init__(self, initial: int = 24, c_min: int = 4, c_max: int = 48) -> None:self.limit, self.c_min, self.c_max, self.in_flight = float(initial), c_min, c_max, 0def update_window(self, h: ReplicaHealth) -> int:overloaded = h.kv_cache_ratio >= 0.85 or h.ttft_p95_ms > 900.0 or h.waiting_requests > 16if overloaded:self.limit = max(float(self.c_min), math.floor(self.limit * 0.7))else:self.limit = min(float(self.c_max), self.limit + 1.0)return int(self.limit)def try_admit(self, deadline_epoch_s: float, min_budget_s: float = 0.5) -> tuple[bool, str]:if deadline_epoch_s - time.time() < min_budget_s:return False, "429_deadline_exhausted"if self.in_flight >= int(self.limit):return False, "429_aimd_concurrency_shed"self.in_flight += 1return True, "admitted"gate = AimdInferenceGate(initial=24)assert gate.update_window(ReplicaHealth(0.91, 1120.0, 19)) == 16assert gate.try_admit(time.time() + 10.0) == (True, "admitted")
Why does scaling LLM replicas on CPU utilization fail during bursts, and how do AIMD concurrency limits bridge multi-minute cold starts?