Autoscaling Concepts: Reactive, Scheduled and Predictive Scaling, the Right Signal, Cooldowns and Warm Pools
A support app's Monday rush climbs to 9 requests per second, or 36 answers in flight, which needs 5 copies. A reactive autoscaler is late by 4 overloaded minutes; a warm pool, a schedule or a forecast brings that to 0, at 7.0, 7.7 and 7.2 copy hours against 10.0 for always-on.
What you will learn
- Compare reactive, scheduled and predictive autoscaling by when the extra capacity arrives
- Apply the target-tracking rule and see why CPU is the wrong signal for an app that waits on an LLM
- Use a cooldown and a warm pool to cut flapping and the warm-up gap
- Read a side-by-side table of overloaded minutes against copy hours
Before you start
- Latency Math: p50, p95, p99 and the Tail
- Sizing and Autoscaling an Inference Service
Every autoscaler answers one question: when does the extra capacity arrive? There are three answers. Reactive scaling adds copies after the traffic has grown. Scheduled scaling adds them at a time you choose. Predictive scaling adds them because history says the rush is coming. On the way we'll pick the right metric for an AI app, and meet the cooldown and the warm pool.
All the numbers come from a small minute-by-minute simulator of one Monday morning, 8:30 to 10:30.
Monday morning at the help desk
Our example is a support-ticket app with an AI assistant. Every customer question becomes an AI answer, and each answer takes about 4 seconds, mostly spent waiting on the language model provider.
At 8:30 it is quiet, about 1 request per second. Between 8:52 and 9:02 the rate climbs to 9 requests per second. Little's law tells us how much work is open at once:
in flight = rate x time = 9 req/s x 4 s = 36 answers in flight
How many copies?
One copy of the app serves 10 answers in flight comfortably. We don't aim for 10, though. We aim for 8, so every copy keeps a little headroom. That 8 is the target.
- At the peak: 36 / 8 = 4.5, rounded up to 5 copies.
- At night: 1 request per second is 4 in flight, and 4 / 8 needs only 1 copy. We keep a minimum of 2, so one failure never takes the app down.
(The full sizing method, from one replica's capacity to a replica count, is in Sizing and Autoscaling an Inference Service. Here we care about timing.)
So we need 5 copies at nine and 2 at night. A reactive autoscaler adds the fifth copy after it sees the load. A scheduled one adds it at 8:45, because you wrote that rule. A predictive one adds it a few minutes early, because the last four Mondays looked the same.
Reactive: the target-tracking loop
Reactive scaling is a loop that runs every minute: measure the metric, compare it with the target, decide how many copies you need, act, wait, and measure again. The most common rule is target tracking:
desired copies = ceil(current copies x metric / target)
At 9:10, two copies would each hold 18 answers. 2 x 18 / 8 = 4.5, rounded up, so the autoscaler asks for 5.
In the simulator the "how many" part is one small function. It also clamps to the floor of 2 and a ceiling of 12:
import math
ANSWER_S = 4 # seconds per AI answer
PER_COPY = 10 # answers in flight one copy serves
TARGET = 8 # target answers in flight per copy
MIN_C, MAX_C = 2, 12 # floor and ceiling
def need(x):
return max(MIN_C, min(MAX_C, math.ceil(x / TARGET)))
Why CPU is the wrong signal
Many autoscalers watch CPU by default. For an AI app that goes wrong. Look inside one copy at 9:10: 10 answers are active and 8 more wait in its queue. The active ones spend their time waiting on the model provider, and waiting uses almost no CPU.
2 copies at 9:10: 18 per copy, CPU 16%
CPU rule: ceil(2 x 16 / 60) = 1
in-flight rule: ceil(2 x 18 / 8) = 5
With a CPU target of 60%, the CPU rule says 1 copy. Customers are queuing and the autoscaler thinks you have too many copies. The in-flight rule, at the same minute, says 5.
The rule: scale on the thing that fills up first.
| Kind of work | Signal to scale on |
|---|---|
| Number crunching (resizing images) | CPU is fine |
| An API that calls a model | Requests in flight per copy |
| Background workers | Queue depth: messages waiting / messages one worker handles |
| A server that runs the model itself | Tokens in flight, or time to first token |
The reactive gap
Now watch the reactive autoscaler minute by minute. It sees the metric one minute late, and a new copy needs 3 minutes to start. Each cell below is demand / capacity, in answers in flight.
reactive demand/capacity:
8:50 4/20 8:51 4/20 8:52 4/20 8:53 7/20 8:54 10/20 8:55 14/20
8:56 17/20 8:57 20/20 8:58 23/20 8:59 26/20 9:00 30/30 9:01 33/30
9:02 31/30 9:03 31/40 9:04 38/40 9:05 38/50 9:06 31/50
That gap of four red minutes is the price of reacting instead of preparing.
Cooldown: scale out fast, scale in slowly
Traffic also wobbles. During the peak the rate jumps between about 8 and 9.5 requests per second. Without a pause, the autoscaler removes a copy in every dip and orders it back in every bump, and each returning copy needs 3 minutes again.
The fix is a cooldown: before removing a copy, the load must stay low for 10 minutes.
| Reactive, two hours | Scaling actions | Overloaded minutes |
|---|---|---|
| No cooldown | 26 | 15 |
| 10-minute cooldown | 5 | 4 |
Warm pool: shorten the warm-up
Much of the gap is warm-up. A new copy has to boot, pull its image, load its settings and open its connections. A warm pool keeps a few copies already prepared but not serving. When the autoscaler asks, one joins in about 1 minute instead of 3.
Same reactive rule, 1-minute warm-up: overloaded minutes drop from 4 to 0, and serving cost stays at 7.0 copy hours. The pool itself isn't free, since prepared copies still cost something to keep, so keep it small.
Scheduled scaling: a calendar rule
When the rush has a fixed time, you don't need to wait for it. A scheduled rule says: every Monday from 8:45 to 9:45, keep at least 5 copies. The copies are ready before the first customer arrives, and the run has zero overloaded minutes.
It costs a little more, 7.7 copy hours, because copies wait from 8:45 for a rush that starts later. And the calendar is only as good as you. A holiday, or a marketing email on a Tuesday, and the rule is wrong.
Predictive scaling: history writes the calendar
Predictive scaling writes that calendar for you. Our last four Mondays peaked at 8.5, 9.0, 9.5 and 9.0 requests per second. The average is 9, so the forecast for 9:10 is 36 in flight.
forecast at 9:10 from [8.5, 9.0, 9.5, 9.0]: 36 in flight
The autoscaler orders copies 5 minutes ahead of the forecast, which covers the 3-minute warm-up with 2 minutes to spare. Zero overloaded minutes, at 7.2 copy hours, because capacity climbs with the forecast instead of jumping at a fixed time. A forecast only knows the past, though. A spike nobody has seen before still needs the reactive rule as a safety net.
Side by side
Here is the simulator's summary for the same two hours:
mode over_min copy_h peak actions
reactive 4 7.0 5 5
scheduled 0 7.7 5 3
predictive 0 7.2 5 5
warm pool 0 7.0 5 5
no cooldown 15 5.8 5 26
always 5 copies: 0 overloaded, 10.0 copy hours
| Approach | Overloaded minutes | Copy hours | Catch |
|---|---|---|---|
| Always 5 copies | 0 | 10.0 | Pays for the peak all day |
| Reactive | 4 | 7.0 | Always a step behind |
| Reactive + warm pool | 0 | 7.0 | Plus the small cost of the pool |
| Scheduled | 0 | 7.7 | Wrong on holidays and surprise days |
| Predictive | 0 | 7.2 | Only knows past patterns |
Prepare, then react
In practice you combine them. Use scheduled or predictive scaling for the shape you expect. Keep reactive scaling on the right signal, requests in flight, for the surprise. Add a cooldown so it stays calm, and a small warm pool so the gap stays short. Prepare for the traffic you expect, and react to the traffic you get.
The queue is also the stage that blows up p95 latency first, as shown in Where Time Goes in an LLM Request. For GPU model servers, where warm-up means loading weights, see Serving open models with vLLM.
Common mistakes
- Scaling an LLM-calling API on CPU. Waiting is cheap on CPU, so the rule scales down while users queue.
- Targeting 100% of a copy's capacity. Aim below it (8 of 10 here) so a burst has room while new copies start.
- No minimum. A floor of 2 keeps one failure from taking the app down at night.
- Scaling in as fast as out. Without a cooldown the run took 26 actions and 15 overloaded minutes.
- Trusting the forecast alone. Keep the reactive rule on underneath it.
Try it yourself
Take the Monday numbers and change one thing: what if each answer took 6 seconds instead of 4? Work out the in-flight count at 9 requests per second, the copies you need at a target of 8, and how far ahead a predictive autoscaler must order if warm-up is still 3 minutes.
Related course on Udemy
The Python Architect Masterclass: Full Stack to AI Engineer
Python, Django, FastAPI, React, Docker, AWS, LLMs, RAG, agents and MCP, from first steps to AI engineer.View on Udemy ↗: The Python Architect Masterclass: Full Stack to AI Engineer (paid course, opens in a new tab)Related posts
Fallback Models for an LLM App: A Chain That Checks Region and Fit, Flags Degraded Answers and Gets Rehearsed
When the main model goes down, the backup has to be allowed to take the data, able to read the whole request and tested before the bad day. A simulated four-model chain for an EU customer: a 6,000-token request lands on mid-eu, flagged degraded; a 10,000-token request is served by nobody, on purpose.
Back Pressure for LLM Traffic: Bound the Queue, Give Chat Its Own Lane, Count Tokens, Cancel When the Caller Leaves
A bulk upload buries the chat. In a small simulation, one shared queue grows to 199 waiting and the middle chat answer takes 80.2 s. A bound plus a chat lane brings it to 0.35 s while 178 bulk jobs are told to retry in 10 s, and cancelling abandoned calls saves 21,000 wasted tokens.
Load Balancing LLM Traffic: Count the Work, Weigh the Prefix Cache, Check Real Health, Drain Before Deploys
Six GPU replicas, two at 95% and four at 30%: round robin counts requests, and requests aren't equal. In a small simulation, least outstanding requests cuts p95 from 6.52 s to 3.05 s, prefix affinity lifts cache hits to 95% but pushes p95 to 11.45 s, a real health check takes errors from 48 to 2, and draining cuts 0 answers instead of 4.
A Message Queue for Document Ingestion: At Least Once, Leases, an Idempotent Consumer and a Dead Letter Queue
A queue doesn't lose a document, but it can hand one out twice. In a small simulation, a worker crash makes document two go from 3 to 6 chunks and the index holds 11 when the documents hold 8. An idempotent consumer brings it back to 8 with the same two deliveries, and a limit of three tries moves a poison file to a dead letter queue.
