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

Reserved vs On-demand

A reserved instance is paid for whether it runs or not, so it pays off exactly when it runs more than reserved price ÷ on-demand price of the time. Applied layer by layer to a load profile, that threshold picks the level to reserve: the floor the profile spends most of its day above, with everything on top of it bought on demand.

u* = reserved price / on-demand price = 7¢/12¢ = 7/12 = 58.3% raise the reserved level while the share of hours above it exceeds u* optimum 12 instances 11 of 24 hours (45.8%) are still above $51.84 → $37.44 a day saves $14.40, or 27.8% reserve the peak instead: $60.48, which is $8.64 worse than reserving none spot beats on demand only while q < (d − s)/d = 2/3
One price ratio, applied one instance at a time

Core ideas

What this lesson establishes

The threshold is a single division. The work is in applying it to a layer of the fleet rather than to the fleet as a whole.

1

A reserved instance is a bet on hours, and u* is the odds

Reserved costs r an hour for every hour of the term whether or not it serves anything; on demand costs d an hour only when it runs. Over any period, reserving is cheaper exactly when the instance runs more than u* = r/d of it. At 7¢ and 12¢ that is 7/12, or 58.3% of the hours — and nothing else about the profile enters the threshold.

2

Reserve a level, not a fleet

The decision is taken one instance at a time, from the bottom of the profile upward. The first instance runs all twenty-four hours and is an easy reservation; the thirty-sixth runs for one hour and is an obvious mistake. Somewhere between them the share of hours above the level falls through u*, and that level is the optimum.

3

The marginal rule never evaluates a total

Raising the reserved level by one costs 24r a day and saves d for every hour the profile is above the new level. So raise while hours above × d > 24r, which is exactly hours above / 24 > u*. Costing every level from zero to the peak gives the same answer — 12 here — and the two agreeing is the check.

The material

The price ratio, the level it picks, and what spot really costs

Where u* comes from, the marginal argument that turns it into a level, the two ways of getting that level wrong, and an interruption model for spot.

Definition · Break-even utilisation

Let r be the price of a reserved instance-hour, charged for every hour of the term, and d the price of an on-demand instance-hour, charged only when the instance runs. Over a term of H hours an instance that runs uH of them costs rH reserved and duH on demand, so reserving is cheaper exactly when

u > u* = r/d.

The term length H cancels, so u* is a property of the two prices alone.

7¢ against 12¢ gives u* = 7/12 = 58.3%. Read it as a duty cycle: an instance that will be up for more than fourteen hours of every twenty-four should be reserved, and one that will not should not be. Every other question on this page is which instances those are.

From a threshold to a level

Stack the profile as layers. Layer k is the k-th instance, and it runs during exactly those hours when demand is at or above k. Its utilisation is therefore the share of hours the profile spends above k, which falls as k rises — so there is one crossing, and it is the level to reserve up to.

r = $0.07000/h d = $0.12000/h u* = r/d = 7/12 = 58.3% raising the reserved level from k to k+1: costs 24r = 24 × $0.07000 = $1.68 a day saves h·d where h = hours the profile is above k+1 worth it while h·d > 24r, i.e. h/24 > r/d = u* the crossing lands at 12 instances: hours above 12 11 of 24 = 45.8% < 58.3% stop and a scan over every level 0 … 36 agrees: 12

The marginal rule is worth preferring because it never evaluates a total bill. It compares one day of reservation against one day of the hours that reservation covers, and it is the same argument that picks an order quantity or a staffing level: raise while the margin is positive, stop when it turns.

Example · The bill at the three candidate levels

This profile uses 432 instance-hours a day and peaks at thirty-six instances. All on demand: 432 × $0.12 = $51.84. Reserved to 12: 288 reserved hours at $0.07 plus 144 on-demand at $0.12, which is $20.16 + $17.28 = $37.44, saving $14.40 a day — 27.8%. Reserved to the peak of thirty-six: 864 × $0.07 = $60.48, which is $8.64 worse than reserving nothing at all.

Why reserving the peak is worse than reserving nothing

The peak hour’s instances run for one hour in twenty-four, a utilisation of 4.2% against a threshold of 58.3%. Reserving them buys twenty-three idle hours each, at full price, every day of the term. The instinct behind it is a good one — the peak is the part that hurts — but the peak is precisely the part with the worst duty cycle, and a commitment is a bet on hours rather than on importance.

The opposite error is quieter. Reserving nothing leaves the bottom twelve instances, which run every hour of every day at 100% utilisation, paying the on-demand premium for capacity that is never not needed. That is the $14.40 a day the optimum recovers.

Spot is not simply the cheapest column

A spot instance-hour at s can be reclaimed part-way through, and the work still has to be done, so an interrupted hour is re-bought on demand. With a reclaim probability q the expected delivered cost is s + q·d, which at s = $0.04, d = $0.12 and q = 15% is $0.058 — genuinely below $0.12, but nowhere near the headline $0.04.

delivered cost of a spot hour s + q·d beats on demand while s + q·d < d q < (d − s)/d = (12 − 4)/12 = 2/3 at q = 15%: $0.04000 + 0.15 × $0.12000 = $0.05800 delivered burst layer on spot: $28.51 a day, against $51.84 all on demand

So spot is a third arm on the same comparison rather than a free lunch: it wins while interruptions are rarer than two in three, and it is the burst layer — the one with the utilisation too low to reserve — that it belongs on.

Everything above assumes the profile is known. When it is a forecast with a distribution around it, the quantity to commit to is a quantile of that distribution rather than a level of a known shape, which is the newsvendor problem — solved in “The Newsvendor Problem” in the Operations Research course “Inventory Models”, with the under-commitment and over-commitment costs in the shortage and overage roles.

Interactive

Reserved vs on-demand

Reserve the floor, buy the spikes, and price spot's interruptions

Reserved, on-demand and spotthe break-even is a price ratio; the level is a quantile
reservedbought on demand

Method

Choosing what to commit to

The threshold first, because it is one division and it decides how the profile is read.

1

Divide the reserved price by the on-demand price

u* = r/d. That is the duty cycle a commitment needs to pay for itself, and it is independent of the term, the profile and the size of the fleet. At 7¢ and 12¢ it is 58.3%, or just over fourteen hours a day.

2

Turn the profile into hours-above-a-level

For each level k, count the hours the profile is at or above k. That count divided by the period is the k-th instance’s utilisation, and it is what the threshold is compared against.

3

Raise the level while the share above it exceeds u*

Stop at the first level where it does not. Here that is 12, with 45.8% of hours above it against a threshold of 58.3%. No total has been computed at any point in this step.

4

Cost the whole plan once, and cost two wrong plans beside it

The optimum, reserving nothing, and reserving the peak: $37.44, $51.84 and $60.48 a day. The third being worse than the second is the number that makes the argument, and it is invisible if only the recommendation is priced.

5

Price spot with its interruption rate, not its sticker

s + q·d is what a delivered spot hour costs, and q < (d − s)/d is the condition for it to beat on demand at all. Put it on the burst layer, which is the layer whose utilisation was too low to reserve.

Commitments, levels and delivered prices

Score 0 / 0

7¢ reserved against 12¢ on demand, on an evening-peaking profile

The profile uses 432 instance-hours a day and peaks at thirty-six instances. The threshold is computed once and then applied upward.

u* = r/d = 0.07/0.12 = 7/12 = 58.3% ⇒ a commitment needs 14.0 of every 24 hours to pay marginal test, level k → k+1: cost 24 × $0.07000 = $1.68 a day save (hours above k+1) × $0.12000 raise while hours above > 14 … the crossing lands at level 12 hours above 12: 11 of 24 = 45.8% < 58.3% so stop at 12 full scan of levels 0 … 36 also returns 12 ✓ cost a day, three plans: reserve nothing 432 on demand $51.84 reserve 12 288 res + 144 on demand $37.44 −$14.40 (27.8%) reserve the peak 864 reserved $60.48 +$8.64 spot on the burst layer, s = $0.04000, q = 15%: delivered $0.04000 + 0.15 × $0.12000 = $0.05800 an hour plan 288 res + 144 spot $28.51 −$23.33 and spot beats on demand only while q < (12 − 4)/12 = 2/3

The +$8.64 line is the one to remember. Reserving the peak is not a cautious version of reserving the optimum — it is worse than making no commitment at all, because the instances it commits to are the ones that run for an hour a day.

The spot block shows why an interruption model is not optional. The sticker price is a third of on demand; the delivered price is under half of it; and at a reclaim rate of two in three the two are equal and spot stops being cheap at all. Quoting $0.04 without q is quoting a price for something you may not receive.

For a faded attempt, raise the reserved price to 10¢ and leave on demand at 12¢. Compute the new u* first and predict from it alone whether the optimal level rises or falls, then find the level and the three daily bills in the lab and say how much of the original saving survived.

Common mistakes

1
Reserving for the peakThe peak is the part of the profile with the worst duty cycle, so it is the worst possible thing to commit to. Here it costs $60.48 a day against $51.84 for no commitment at all. The instinct — cover the part that hurts — is answering a reliability question with a pricing instrument.
2
Comparing total bills instead of the margin“Reserving is 27.8% cheaper” is an outcome, not an argument, and it cannot tell you whether 11 or 13 would have been better. The rule that can is the marginal one: raise while the share of hours above the level exceeds u*. Costing every level is then the check on it, not the method.
3
Quoting spot at its sticker price$0.04 is the price of an hour that may be taken back. With 15% reclaimed and the work re-bought on demand, the delivered price is $0.058, and above a reclaim rate of 2/3 spot costs more than on demand outright. A spot saving with no q beside it is not a number.

Check your understanding

✓
Finish when a commitment is justified by a duty cycle rather than by a discount.

You should be able to compute u* = r/d, turn a profile into hours-above-a-level, pick the reserved level by the marginal rule and confirm it by scanning every level, and price both the reserve-nothing and reserve-the-peak plans beside the one you recommend.

Note: Reservation and on-demand both assume capacity appears when it is asked for. It does not: instances take time to boot, and during that window demand is served by the fleet that already exists. “Autoscaling Lag” puts an area on that window, and the surprise is that without a warm reserve the requests missed during the boot are never made up.

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.