Learn
Lesson · Scaling Laws and Cost · Paying for the peak

Autoscaling Lag

Capacity does not arrive when it is ordered. During a ramp the fleet is permanently the boot window behind demand, and the requests lost to that gap are the area between two lines: a triangle while the boot and the ramp overlap, then a rectangle for the rest of it. The only thing that removes it is capacity that was already warm.

shortfall = r·τ·(D − τ/2) r = 50 rps/s, τ = 90 s, D = 300 s = 4 500 × 255 = 1 147 500 requests triangle 202 500 + rectangle 945 000 = the same 1 147 500 the fleet is permanently r·τ = 4 500 rps behind worst instant λ = 9 500, μ = 5 000, ρ = λ/μ = 19/10 > 1 a warm reserve of r·τ = 4 500 rps makes the shortfall exactly zero
A trapezoid, and the reserve that flattens it

Core ideas

What this lesson establishes

The geometry is easy. What is worth taking from the page is what the area means: not slow requests, but requests that were never served.

1

The fleet is behind by r·τ, constantly

Demand rises at r a second; capacity responds to the demand of τ seconds ago, because that is when the instances now arriving were ordered. So once the ramp is under way the gap is r·τ and it stays there: 50 × 90 = 4 500 rps here, at every instant from the boot window until the ramp stops. It is not a transient that closes as the fleet grows.

2

The shortfall is an area, and it has two parts

While the boot window and the ramp overlap, the gap is growing and the region is a triangle of ½·r·τ² = 202 500 requests. After that the gap is constant and the region is a rectangle, r·τ·(D − τ) = 945 000. Added, they are r·τ·(D − τ/2) = 1 147 500 — the closed form, and the two routes must agree.

3

Above ρ = 1 there is no steady state, so the backlog is not a queue

ρ here is λ/μ, the same definition “λ, μ and ρ” gives, with μ the capacity actually in service rather than the capacity ordered. At the worst instant λ = 9 500 against μ = 5 000, so ρ = 19/10. Above one there is no steady state at all: the backlog grows at λ − μ = 4 500 requests a second, and 1/(1 − ρ) is not a number.

The material

A boot window, the area it costs, and the only thing that removes it

Where the trapezoid comes from, why the backlog never drains, and what a warm reserve is actually buying.

Definition · Autoscaling shortfall

Let demand rise from a level the fleet already serves at a rate r requests per second per second, for a ramp of duration D. Let τ be the time between ordering an instance and it serving traffic. With no warm reserve, the shortfall — the number of requests demanded and not served — is

r·τ·(D − τ/2) for D ≥ τ,

which is the area between the demand line and the capacity line over the ramp.

The derivation is geometry. For the first τ seconds capacity does not move at all, so the gap grows linearly from zero to r·τ: a triangle of area ½·r·τ². After that, capacity rises at the same rate as demand but τ seconds later, so the gap is a constant r·τ for the remaining D − τ seconds: a rectangle of area r·τ·(D − τ).

r = 50 rps/s τ = 90 s D = 300 s base load 5 000 rps triangle ½ · r · τ² = ½ × 50 × 8 100 = 202 500 rectangle r · τ · (D − τ) = 4 500 × 210 = 945 000 ------------ total 1 147 500 requests closed form r · τ · (D − τ/2) = 4 500 × 255 = 1 147 500 ✓

Both routes give the same integer, which is the check. The closed form is the area of a trapezoid: the mean of the two gaps — zero at the start and r·τ from the boot window on — taken over the ramp, with the τ/2 recording that the gap spent the first boot window opening rather than open.

What the area is made of

It is worth being exact about what 1 147 500 counts. It is not requests that were slow; it is demand that arrived while there was no capacity for it. Whether those requests queue, retry or fail is a property of the system in front of the fleet, and every one of those outcomes is bad in a different way.

moment λ μ in service ρ = λ/μ t = 0 s ramp starts 5 000 5 000 1 t = 45 s mid-boot 7 250 5 000 29/20 t = 90 s τ: first ready 9 500 5 000 19/10 t = 300 s D: ramp ends 20 000 15 500 40/31 t = 390 s caught up 20 000 20 000 1

Every row above ρ = 1 is a row with no steady state. The backlog grows at λ − μ for as long as the row lasts, which at the worst instant is 4 500 requests a second. This is the same ρ as “λ, μ and ρ”, and the only thing this page adds is that μ must be the capacity in service rather than the capacity requested — the difference between those two is exactly the subject of the lesson.

The backlog never drains

Look at the last row. When the ramp stops, capacity catches up and the two lines end level at 20 000 rps. Level means no spare: there is no surplus with which to work through what accumulated, so the backlog built during the ramp is still there when the ramp is over. It drains only when demand falls, or never.

That is why “autoscaling handles spikes” is the wrong model. Autoscaling handles growth: given enough time it tracks a rising load with a fixed lag and a bounded gap. A spike is precisely the case where there is not enough time, and the mechanism arrives after the event it was meant to absorb.

Example · The reserve that removes it exactly

Hold r·τ = 4 500 rps warm and the shortfall is zero, not small. The reserve covers exactly the capacity the boot window costs: for the first τ seconds it absorbs the growing gap, and by the time it is exhausted the first ordered instances are in service. Set the reserve to 2 000 rps instead and the shortfall is reduced rather than removed — the lab shades what is left.

A reserve is idle capacity, which is the waste of “Utilisation and Waste” deliberately bought. That is the honest framing of the trade: the shortfall is priced in requests and the reserve is priced in instance-hours, and choosing between them is a decision rather than an optimisation.

Two knobs change r·τ without buying a reserve, and both are worth more than they sound. Halving τ — a smaller image, a warmer pool, a faster health check — halves the gap and quarters the triangle. Scaling on a leading signal rather than on the utilisation that results from it starts the boot earlier, which is the same saving bought with a prediction instead of with money.

Interactive

Autoscaling lag

A boot window is a shortfall with an area, and a reserve is what removes it

Autoscaling lagthe fleet is always r·τ behind, and the gap has an area
demandcapacity in servicethe shortfallτ, the boot window

Method

Sizing a boot window against a ramp

The gap first, because it is one multiplication and everything else is its area.

1

Multiply the ramp rate by the boot time

r·τ is how far behind the fleet runs for the whole of the ramp: 4 500 rps here. Quote it in the same units as the load, because it is directly comparable with the base load — 4 500 against 5 000 is a fleet running at nearly double what it can serve.

2

Compute the area both ways

Triangle plus rectangle, then r·τ·(D − τ/2). They must agree to the request. Two routes to one figure is what stops a factor of two in the triangle going unnoticed, and a factor of two here is half a million requests.

3

Find the worst instant and take ρ there

λ/μ with μ the capacity in service. If it is above 1, say so in those terms: no steady state, backlog growing at λ − μ. A utilisation above one is not a busy system, and reporting it as 190% invites it to be read as one.

4

Check whether there is any surplus after the ramp

Compare capacity and demand at the end. Level means the backlog never drains on its own. This single comparison is what turns the shortfall from a transient into a permanent debt, and it is one subtraction.

5

Price the reserve against the shortfall

r·τ of warm capacity removes the area exactly. That capacity is idle most of the time, so the decision is instance-hours against requests, and both sides of it now have numbers.

Boot windows, areas and reserves

Score 0 / 0

A 90-second boot against a 300-second ramp at 50 rps a second

The base load is 5 000 rps and the fleet is exactly sized for it when the ramp begins.

r = 50 rps/s τ = 90 s D = 300 s the constant gap r·τ = 50 × 90 = 4 500 rps first 90 s gap grows 0 → 4 500 triangle ½ × 90 × 4 500 = 202 500 requests next 210 s gap constant at 4 500 rectangle 210 × 4 500 = 945 000 requests ------------- 1 147 500 requests check r·τ·(D − τ/2) = 4 500 × (300 − 45) = 4 500 × 255 = 1 147 500 ✓ worst instant, t = 90 s: λ = 5 000 + 50×90 = 9 500 rps μ = 5 000 rps ρ = λ/μ = 19/10 > 1 ⟹ no steady state backlog grows at λ − μ = 4 500 requests a second end of the ramp, t = 300 s: λ = 20 000, μ = 15 500 the fleet levels at t = 390 s: λ = μ = 20 000, and nothing spare ⟹ the 1 147 500 never drains with a warm reserve of r·τ = 4 500 rps: shortfall = 0

The check line matters more than it looks. ½·r·τ² + r·τ·(D − τ) and r·τ·(D − τ/2) are the same quantity written two ways, and computing both is how you find out that you used D where you meant D − τ.

The nothing spare line is the one that changes what the shortfall means. If the fleet ended above demand, the backlog would clear and the shortfall would be a latency event. It ends level, so the shortfall is a permanent loss of just over a million requests, and no later behaviour of the autoscaler recovers it.

For a faded attempt, halve the boot window to 45 s and keep everything else. Predict before computing what happens to the triangle and to the total — one of them falls by a factor of four and the other does not — then read both off the lab and say what a warm reserve would now have to be.

Common mistakes

1
Believing autoscaling handles spikesIt handles growth, with a fixed lag and a bounded gap. A spike is the case where the ramp is short against τ, and there the mechanism arrives after the event: over a 90 s boot window nothing whatever happens except that the gap opens to r·τ. The instrument that covers a spike is capacity that is already warm.
2
Taking ρ against the capacity that was orderedμ is the capacity in service. Counting instances that are booting puts ρ below one and reports a busy system, when the truth is 19/10 and an unbounded backlog. The boot window is precisely the interval in which the two counts differ, so using the wrong one here erases the whole effect.
3
Reporting the shortfall as latencyThe area is demand that arrived with no capacity behind it. It becomes latency only if something queues it and there is later surplus to work it off; here the fleet ends level with demand, so there is none. Calling 1 147 500 requests “a slow period” makes a permanent loss sound like a transient.

Check your understanding

✓
Finish when a boot window reads as an area rather than as a delay.

You should be able to compute r·τ, produce the shortfall by both the two-region route and the closed form, evaluate ρ = λ/μ at the worst instant with μ the capacity in service, say whether the backlog drains, and name the reserve that removes the area.

Note: That is the last of the three ways capacity is paid for. What remains is the cost of a single request, and the surprise in it: the term that dominates a per-request bill is usually not the one that was sized. “Cost per Request” decomposes it into four, and the largest of them is the bytes going out of the door.

Kept in this browser only, for you. Nothing is sent anywhere and nothing checks it. Carry it to another device.

Feedback and recommendations

Something to change about this lesson? Write it down, tick it off when it is handled, and export the list when you want to act on it. Kept in this browser only: nothing is sent anywhere, and nobody is notified.

No recommendations yet for this lesson.