Before you start: words you need#
| Word | Plain meaning |
|---|---|
| Reactive scaling | Adding replicas after a signal (queue wait, KV cache use) shows load has risen. |
| Predictive scaling | Adding replicas on a schedule, before load that you know is coming. |
| Cold start | Time from “add a replica” to “it serves traffic”: get a GPU node, pull the image, load weights, warm up (20.g, 20.h). |
| KEDA | Kubernetes Event-Driven Autoscaling: feeds the Kubernetes autoscaler from Prometheus queries, cron schedules and queues. |
| Degradation ladder | A pre-agreed list of things to give up, in order, when load exceeds capacity. |
| Warm pool | Replicas that are loaded and ready but idle, so they can take traffic in seconds. |
| Thrashing | Scaling up and down over and over, paying a cold start each time. |
1. What is it?#
20.g covers the mechanics: which signal to scale on, the HPA, cold starts, draining. This lesson is the operating policy: what to configure for a real service, what autoscaling can and cannot do, and what happens when it cannot keep up.
The honest summary: autoscaling for LLM inference follows slow, predictable change. It does not catch spikes. A replica takes minutes to start, so the scaler reacts on a timescale of 5–15 minutes.
WORKS FOR DOES NOT WORK FOR
daily and weekly cycles a launch announcement going viral
gradual growth a 90-second burst
scheduled events a retry storm (20.e)
an upstream system replaying its backlogWhat handles spikes is headroom (23.b), paid for all the time, and a degradation ladder for when even that runs out.
flowchart LR
P["Schedule<br/><small>known daily shape</small>"] --> W{"Replicas wanted"}
S["Signals<br/><small>queue wait, KV cache use</small>"] --> W
W -->|"more"| UP["Add now"]
UP --> CS["Cold start<br/><small>node, image, weights, warm-up</small>"]
CS --> R["Serving"]
W -->|"fewer, for 15 min"| DN["Drain, then remove one"]
R --> S
DN --> S
W -->|"still short"| L["Degradation ladder"]
class P,S neutral
class W queue
class UP,R compute
class CS,L warn
class DN io2. Why does it matter?#
- Money. A fleet sized for the daily peak all day pays for idle GPUs every night. The simulation in section 6 uses 43% fewer node-hours by following the daily shape.
- The SLO. A policy that scales too slowly or thrashes breaks latency objectives at exactly the moments traffic is highest.
- Large models make it harder. Each replica is many GPUs and many gigabytes of weights, so every mistake costs minutes.
3. Simple analogy#
A supermarket opens more tills at 5 p.m. every weekday because it knows the evening rush comes (predictive). It also calls staff from the back when queues grow (reactive), but they take a few minutes to arrive. When a coach party arrives unannounced, neither helps in time: the queue grows, and the manager starts sending people with small baskets to the self-service tills (the degradation ladder).
4. Tiny example#
A node takes 10 minutes from launch to serving. Traffic jumps 60% for 20 minutes at 13:00.
13:00 burst starts; queue wait rises past the trigger
13:01 scaler asks for 4 more nodes
13:11 they finish cold start and take traffic
13:00–13:10 ten minutes over capacity; requests queue, then are shed
13:20 burst ends; the extra nodes idle for 15 minutes, then leave one at a timeThe scaler did its job and users still saw ten bad minutes. Only headroom, or shedding, covers those.
5. Technical explanation#
A production policy#
Combine a schedule for the known shape with reactive triggers for the rest. The metric names are vLLM’s (19.c); other engines expose similar ones.
# KEDA ScaledObject: predictive (cron) + reactive (Prometheus), asymmetric windows
apiVersion: keda.sh/v1alpha1
kind: ScaledObject
metadata:
name: chat-70b
spec:
scaleTargetRef:
name: chat-70b # the Deployment (or LeaderWorkerSet) running the engine
minReplicaCount: 6 # baseline traffic: never below, never zero for a big model
maxReplicaCount: 40 # must fit your GPU quota (see below)
pollingInterval: 15
advanced:
horizontalPodAutoscalerConfig:
behavior:
scaleUp:
stabilizationWindowSeconds: 60
policies:
- {type: Percent, value: 50, periodSeconds: 60}
- {type: Pods, value: 4, periodSeconds: 60}
selectPolicy: Max
scaleDown:
stabilizationWindowSeconds: 900 # 15 minutes of low load first
policies:
- {type: Pods, value: 1, periodSeconds: 300}
triggers:
- type: cron # predictive: the weekday ramp
metadata:
timezone: Asia/Kolkata
start: 0 8 * * 1-5
end: 0 22 * * 1-5
desiredReplicas: "14"
- type: prometheus # reactive: queue wait, the SLO signal
metadata:
serverAddress: http://prometheus.monitoring:9090
query: |
histogram_quantile(0.95,
sum by (le) (rate(vllm:request_queue_time_seconds_bucket{model_name="chat-70b"}[2m])))
threshold: "0.3" # p95 queue wait above 300 ms (its TTFT budget share)
- type: prometheus # reactive: memory, the binding constraint
metadata:
serverAddress: http://prometheus.monitoring:9090
query: avg(vllm:kv_cache_usage_perc{model_name="chat-70b"})
threshold: "0.8"KEDA takes the highest replica count any trigger asks for, so the schedule sets a floor and the signals add to it. What makes this a production policy rather than a default:
- A floor from baseline traffic. Never scale a large model to zero.
- Asymmetric windows: up within a minute, down only after 15 minutes, one replica at a time. Scale-down is cheap to delay and expensive to get wrong (20.g).
- Queue wait as the main trigger, with the threshold taken from its share of the TTFT budget (23.a). KV cache use is the early warning.
- A schedule. It costs nothing and scales before the load arrives.
The rest of the chain must scale too#
A replica cannot start without a GPU node. If nodes come from a cluster autoscaler or a provisioner (Karpenter, a cloud’s node pools), that adds minutes, and it fails outright if the cloud has no capacity of that GPU type in the zone. So:
- Check
maxReplicaCountagainst your GPU quota and reservations. An autoscaler that asks for pods that can never be scheduled just leaves them pending. - Reserve the base, rent the burst. Reserved or owned capacity for the floor, on-demand for the reactive part, spot only for work that can be interrupted (23.c).
- Scale the gateway and router too. They are cheap, but a CPU tier that saturates first looks like a GPU problem.
Predictive scaling#
Most LLM traffic follows a strong daily and weekly pattern:
consumer product business product
trough 03:00–05:00 ≈ 20% of peak near zero at weekends
ramp 07:00–10:00 sharp 09:00 ramp, lunch dip
peak 19:00–22:00 stops at 18:00Recipe: take 4+ weeks of request logs, compute replicas needed by hour of week, set the schedule from that, keep the reactive triggers on top, and review monthly. It is often the highest-value autoscaling work there is, and it takes an afternoon. Steep ramps (a 09:00 start) gain the most; gentle ramps are mostly absorbed by the headroom of the utilization target.
The newer LLM-aware autoscalers (the llm-d Workload Variant Autoscaler, NVIDIA Dynamo Planner; see the table in 20.g) add queueing models, per-hardware-variant choices and separate prefill and decode pools, but the policy questions in this lesson stay the same.
When you cannot scale in time: the degradation ladder#
You will sometimes be over capacity. Decide in advance what happens, in order:
1. LET BATCHES GROW
accept worse ITL for more throughput (engines do this up to max_num_seqs)
cost: slower streaming, bounded
2. CAP max_tokens FOR LOW TIERS
free tier gets 512 output tokens instead of 2,048
cost: shorter answers for some users
3. SHED LOW-PRIORITY TRAFFIC with 429 + Retry-After
free first, then standard, never premium (20.c, 20.k)
cost: some users refused, honestly and quickly
4. ROUTE OVERFLOW TO A SMALLER MODEL (21.k)
cost: lower quality for overflow traffic
5. ROUTE OVERFLOW TO AN EXTERNAL API
cost: money per token and data-handling rules; far cheaper than an outage
6. QUEUE WITH A LONG DEADLINE (batch tier only)Steps 1–3 should be automatic. Steps 4–6 are business decisions made ahead of time and built as switches you can flip. The alternative to a ladder is the metastable collapse described in 20.e.
Scale to zero, and warm pools#
VIABLE NOT VIABLE
small models that load in seconds large models (minutes to start)
internal tools, development anything user-facing with a latency SLO
rare, bursty use models with long warm-up (compile, graphs)The middle ground for large models is a warm pool: a few loaded, idle replicas that can be promoted in seconds. It is headroom by another name, but one generic pool can serve several models if they share hardware, and engine “sleep” modes or fast weight loading shorten the gap (20.g, 20.h).
6. Under the hood#
One day of traffic (trough at 04:00, peak at 20:00, plus a burst of +60% for 20 minutes at 13:00), 10-minute cold starts, and four policies: a static fleet sized for the worst minute, reactive only, predictive only, and both. “Minutes > 85%” is time when queue wait is climbing; “minutes > 100%” is time past capacity at the SLO.
// autoscale.go — one day of traffic, three scaling policies, minute by minute.
package main
import (
"fmt"
"math"
)
const (
nodeCap = 14.0 // requests/s one node serves at the SLO (23.b)
target = 0.70 // utilization the autoscaler aims for
coldStart = 10 // minutes from "add a node" to "node serves traffic"
downWindow = 15 // minutes of low load before removing a node
minNodes = 2
)
// profile is the predictable daily shape: trough at 04:00, peak at 20:00 (requests/s).
func profile(minute int) float64 {
h := float64(minute) / 60
return 70 + 60*math.Sin((h-14)/24*2*math.Pi)
}
// demand is the profile plus one unpredictable burst: +60% for 20 minutes at 13:00.
func demand(minute int) float64 {
d := profile(minute)
if minute >= 13*60 && minute < 13*60+20 {
d *= 1.6
}
return d
}
func need(rps float64) int { return int(math.Max(minNodes, math.Ceil(rps/(nodeCap*target)))) }
// simulate runs one day. fixed > 0 means a static fleet of that size with no scaling.
func simulate(reactive, predictive bool, fixed int) (hotMinutes, overMinutes int, nodeHours float64) {
ready := need(profile(0))
if fixed > 0 {
ready = fixed
}
var pending []int // minutes at which launched nodes become ready
lowFor := 0
for m := 0; m < 24*60; m++ {
// nodes that finished their cold start join now
for len(pending) > 0 && pending[0] <= m {
ready++
pending = pending[1:]
}
want := ready
if reactive || predictive {
want = minNodes
}
if reactive {
want = need(demand(m)) // what the signal (queue wait, KV usage) asks for now
}
if predictive { // schedule: what the profile will need once a new node is ready
if p := need(profile(m + coldStart + 5)); p > want {
want = p
}
}
if have := ready + len(pending); want > have {
for i := 0; i < want-have; i++ {
pending = append(pending, m+coldStart)
}
}
if want < ready {
lowFor++
if lowFor >= downWindow { // slow, one node at a time
ready--
lowFor = 0
}
} else {
lowFor = 0
}
if demand(m) > float64(ready)*nodeCap*0.85 {
hotMinutes++ // queue wait climbing: SLO at risk
}
if demand(m) > float64(ready)*nodeCap {
overMinutes++ // past capacity at the SLO: shedding or breaching
}
nodeHours += float64(ready+len(pending)) / 60 // you pay for nodes while they start
}
return
}
func main() {
peak := 0.0
for m := 0; m < 24*60; m++ {
peak = math.Max(peak, demand(m))
}
static := need(peak) // a fixed fleet sized for the worst minute of the day
fmt.Printf("%-24s %9s %9s %10s\n", "policy", "min > 85%", "min > 100%", "node-hours")
hot, over, nh := simulate(false, false, static)
fmt.Printf("%-24s %9d %9d %10.0f\n", fmt.Sprintf("static, %d nodes", static), hot, over, nh)
for _, p := range []struct {
name string
reactive, predictive bool
}{{"reactive only", true, false}, {"predictive only", false, true}, {"predictive + reactive", true, true}} {
hot, over, nh := simulate(p.reactive, p.predictive, 0)
fmt.Printf("%-24s %9d %9d %10.0f\n", p.name, hot, over, nh)
}
}Output:
policy min > 85% min > 100% node-hours
static, 14 nodes 0 0 336
reactive only 10 10 190
predictive only 20 12 188
predictive + reactive 10 10 192How to read it:
- Following the daily shape saves 43% of node-hours (336 → ~190).
- The burst costs about ten bad minutes whatever the policy. That is the cold start. Only headroom held all day (the static fleet) or the degradation ladder covers it.
- Predictive alone misses the burst entirely (it lasts longer: 12 minutes). Reactive alone copes with this gentle ramp because the 70% target leaves room; make the ramp steeper (exercise 2) and the schedule starts to earn its place.
7. Performance implications#
- Cold start sets the ceiling. Halving it halves the bad minutes after every burst. Fast weight loading, pre-pulled images and node-local caches (3.g, 20.h) are autoscaling work.
- Scaling events disturb routing. A new replica has an empty prefix cache, so its first minutes are slower and the hit rate dips across the pool (21.h).
- Draining takes as long as the longest stream. Scale-down must wait for in-flight generations or cut them (20.g).
8. Production implications#
- Set the floor from baseline traffic; never zero for a large model.
- Fast up, slow down, one replica at a time.
- Queue wait as the primary signal, KV cache use as the early warning.
- Add a schedule for the daily and weekly shape. Review it monthly.
- Build the degradation ladder and test it with load past capacity.
- Alert on thrashing (several up/down cycles in an hour) and on pods pending for lack of GPUs.
- Track “minutes over capacity” as an SLI: it is what your headroom buys.
- Check quota before raising
maxReplicaCount.
9. Common mistakes#
- Scaling on GPU utilization. It is near 100% whenever a kernel runs (22.d).
- Symmetric up and down windows. Thrashing.
- Scale to zero for a large model. The first user waits minutes.
- Expecting autoscaling to catch spikes. It cannot.
- No degradation plan. Collapse instead of controlled shedding.
- No schedule when the daily pattern is obvious.
- An untested scale-down path. Streams cut off mid-answer.
maxReplicaCountabove the GPU quota. Pods that can never run.- Stale metric names. Engines rename metrics between versions (vLLM’s KV metric was once
gpu_cache_usage_perc); a trigger on a missing metric silently never fires.
10. Hands-on exercise#
- Run
autoscale.go. ChangecoldStartto 3 and to 20 minutes. How do the bad minutes after the burst change? - Make the ramp steeper: replace the sine with a step from 30 to 130 requests/s at 09:00. Which policy wins now?
- Extract the hourly profile from four weeks of real or synthetic logs. How much of the variance do hour of day and day of week explain?
- Write the KEDA policy for a service you know, with a schedule, reactive triggers and thresholds taken from its TTFT budget.
- Load-test past capacity and check that each automatic rung of the degradation ladder engages in order.
11. Interview questions#
- Why can autoscaling not catch traffic spikes for LLM services?
- What signal would you scale on, and why not GPU utilization?
- Why are scale-up and scale-down asymmetric?
- What is predictive scaling, and when does it beat reactive scaling?
- Describe a degradation ladder. What is automatic and what is a business decision?
- When is scale to zero viable? What is a warm pool?
- Your autoscaler asked for 10 replicas and got 4. What happened?
12. Further reading#
Checked on 12 November 2026.
- KEDA: Prometheus scaler and cron scaler (v2.21.0 release)
- vLLM production metrics
- llm-d Workload Variant Autoscaler and NVIDIA Dynamo Planner
- Google SRE Book: Handling Overload
- AWS Builders’ Library: Using load shedding to avoid overload
- 20.g (signals, tools, cold starts and draining), 21.k (fallbacks to smaller models)