EC2 Pricing Models
The same instance can cost very different amounts depending on how you buy it. Choosing the right purchase option is often the biggest saving available on an AWS bill.
| Option | Commitment | Typical discount vs On-Demand | Best for |
|---|---|---|---|
| On-Demand | None, pay per second/hour | 0% | Spiky or short workloads, experiments |
| Savings Plans | $/hour of spend for 1 or 3 years | up to ~70% | Steady baseline usage, flexible across instance types |
| Reserved Instances | A specific instance type/Region for 1 or 3 years | up to ~70% | Steady, predictable instances |
| Spot Instances | None, but AWS can reclaim with 2 minutes' notice | up to ~90% | Fault-tolerant batch, CI, big data |
| Dedicated Hosts | A whole physical server | n/a (premium) | Per-socket licences, compliance |
| Dedicated Instances | Hardware not shared with other accounts | premium | Compliance |
| Capacity Reservations | Reserve capacity in an AZ, no discount on its own | 0% | Guaranteed capacity for an event |
The discounts above are rough upper bounds; real numbers depend on instance type, term and payment option (all upfront, partial, no upfront). Check the AWS pricing pages.
Model: comparing options for a year
HOURS = 8760
on_demand = 0.10 # example $/hour
options = {
"On-Demand": on_demand,
"Savings Plan 1y (~28%)": on_demand * 0.72,
"Reserved 3y (~55%)": on_demand * 0.45,
"Spot (~70%)": on_demand * 0.30,
}
for utilisation in (1.0, 0.5, 0.2):
print(f"Instance needed {utilisation:.0%} of the year:")
for name, rate in options.items():
committed = name.startswith(("Savings", "Reserved"))
hours_paid = HOURS if committed else HOURS * utilisation
print(f" {name:<23} ${rate * hours_paid:8.2f}")Instance needed 100% of the year:
On-Demand $ 876.00
Savings Plan 1y (~28%) $ 630.72
Reserved 3y (~55%) $ 394.20
Spot (~70%) $ 262.80
Instance needed 50% of the year:
On-Demand $ 438.00
Savings Plan 1y (~28%) $ 630.72
Reserved 3y (~55%) $ 394.20
Spot (~70%) $ 131.40
Instance needed 20% of the year:
On-Demand $ 175.20
Savings Plan 1y (~28%) $ 630.72
Reserved 3y (~55%) $ 394.20
Spot (~70%) $ 52.56
A commitment is billed whether you use it or not. At 100% utilisation commitments win clearly; at 20% On-Demand beats both commitments. Spot is cheapest in every case, but only works for workloads that tolerate interruption.
Model: break-even utilisation
When is a 1-year commitment worth it? When the instance runs more than the discount factor of the year:
for discount in (0.20, 0.40, 0.60):
break_even = 1 - discount
print(f"discount {discount:.0%}: commit if the instance runs more than {break_even:.0%} of the time "
f"(~{break_even * 8760:,.0f} hours/year)")discount 20%: commit if the instance runs more than 80% of the time (~7,008 hours/year)
discount 40%: commit if the instance runs more than 60% of the time (~5,256 hours/year)
discount 60%: commit if the instance runs more than 40% of the time (~3,504 hours/year)
Spot Instances
Spot uses spare EC2 capacity. The price moves slowly with supply and demand, and AWS may reclaim the instance with a two-minute interruption notice. Design for it: checkpoint work, use many instance types, and run Spot behind Auto Scaling groups that mix On-Demand and Spot.
aws ec2 describe-spot-price-history --instance-types c6g.large \
--product-descriptions "Linux/UNIX" --max-items 2 \
--query "SpotPriceHistory[].[AvailabilityZone,SpotPrice]" --output textSample output:
eu-west-1a 0.025800
eu-west-1b 0.026100Model: a Spot batch job with checkpoints
A 10-hour batch job runs on Spot and is interrupted twice. With checkpoints every hour, at most one hour of work is lost per interruption:
job_hours = 10
interruptions_after = [3.5, 7.2] # running hours at which AWS reclaims the instance
def run(checkpoint_every):
done = wall = lost = 0.0 # work saved, instance-hours used, work redone
for stop_at in interruptions_after:
if wall + (job_hours - done) <= stop_at:
break # the job finishes before this interruption
progress = done + (stop_at - wall)
saved = (progress // checkpoint_every) * checkpoint_every if checkpoint_every else 0.0
lost += progress - saved
done, wall = saved, stop_at # restart from the last checkpoint
wall += job_hours - done
return wall, lost
for every in (1, 0):
wall, lost = run(every)
label = f"checkpoint every {every} h" if every else "no checkpoints"
print(f"{label:<22}: {wall:.1f} instance-hours, {lost:.1f} h of work redone")checkpoint every 1 h : 11.2 instance-hours, 1.2 h of work redone
no checkpoints : 17.2 instance-hours, 7.2 h of work redone
Without checkpoints, each interruption throws away everything done so far. With hourly checkpoints the job finishes in barely more time than an uninterrupted run, at the Spot discount.
Test yourself
Which purchase option can be interrupted by AWS with a two-minute warning?
- On-Demand
- Reserved Instances
- Spot Instances
- Dedicated Hosts
An instance runs 24/7 for the next three years. Which option is usually the cheapest reliable choice?
- On-Demand
- A 3-year Savings Plan or Reserved Instance
- Spot
- Dedicated Host
With a 40% commitment discount, above what utilisation does the commitment pay off?
- 40%
- 60%
- 100%
- 20%