Skip to content
Tutorials Center
My learning

Topics

Lesson 13 of 70 ยท Compute with EC2

On-Demand, Reserved, Savings Plans and Spot

Compare EC2 purchasing options: On-Demand, Savings Plans, Reserved Instances, Spot and capacity reservations, with break-even math and runnable calculators.

The same EC2 instance can cost very different amounts depending on how you buy it. Pay by the second with no commitment and you pay the full price. Commit to steady usage for one or three years and the price per hour can drop by a third or more. Accept that AWS may take the capacity back with two minutes of notice, and it can drop by far more. Choosing well often saves more money than any other single change you can make.

This lesson explains the options and teaches you to reason about them with simple arithmetic. It follows EC2 Instances. Prices change by region, instance type and over time, so the lesson uses made-up round numbers in its calculators and never quotes real price lists. For real figures, use the AWS pricing pages or the pricing calculator.

Everything here is read-only knowledge plus Python stand-ins. The calculators use invented rates to show the shape of the trade-offs. The discount ranges mentioned in the text are typical "up to" figures that AWS advertises, and your actual discount depends on the instance family, term and region.

The purchasing options

Option Commitment Typical discount Best for
On-Demand None. Pay per second (60-second minimum for Linux). None New or unpredictable workloads, short experiments
Savings Plans A fixed dollar amount per hour for 1 or 3 years Up to roughly 70% Steady baseline usage, flexible across instances
Reserved Instances (RIs) A specific instance configuration for 1 or 3 years Up to roughly 70% Steady usage when you want the older, per-instance model
Spot Instances None, but can be interrupted Up to roughly 90% Fault-tolerant, flexible, stateless work
Capacity Reservations None (or tied to a discount plan) None by themselves Guaranteeing capacity in an Availability Zone
Dedicated Hosts / Instances Optional Varies Licensing or compliance needs for single-tenant hardware

On-Demand

You start an instance, you pay for each second it runs, you stop it, the billing ends. There is no discount, and no risk. Use it for anything you do not yet understand, and as the "top layer" above your committed baseline.

Savings Plans

A Savings Plan is a commitment to spend a dollar amount per hour (for example $5 per hour) for one or three years. Usage that the commitment covers is billed at the discounted rate. Anything above it is billed On-Demand. Whether you use the commitment or not, you pay it every hour, which is why you only commit to usage you are confident will continue.

The two main flavors are:

  • Compute Savings Plans apply to EC2 whatever the instance family, size, region, operating system or tenancy, and also to Fargate and Lambda. They are the most flexible and have a slightly lower discount.
  • EC2 Instance Savings Plans are tied to an instance family in one region (for example m7 in eu-west-1) and offer a bigger discount, with flexibility inside that family.

You can pay all upfront, partially upfront or nothing upfront, with the biggest discount for paying upfront. Most teams start with no upfront to preserve cash.

Reserved Instances

Reserved Instances are the older model: you commit to a specific instance configuration for one or three years. Standard RIs give the biggest discount but little flexibility, and Convertible RIs let you exchange for other configurations at a slightly smaller discount. A zonal RI also reserves capacity in one Availability Zone. For new commitments AWS generally steers customers to Savings Plans because they are simpler, so you will mostly meet RIs in existing accounts, and also for some databases (RDS and ElastiCache have their own reserved pricing).

Spot Instances

Spot sells spare EC2 capacity at a steep discount. The catch: when AWS needs the capacity back, it interrupts your instance. You get a warning about two minutes before, through the instance metadata and an EventBridge event. Spot is not an auction in which you place bids any more: you pay the current Spot price for the pool, which changes slowly.

Spot suits work that can be retried or split up:

  • batch processing, CI builds, rendering, data analytics and big-data workers
  • stateless web or API nodes behind a load balancer, mixed with On-Demand ones
  • containers on ECS or EKS that can be rescheduled

It does not suit a single database primary or any job that cannot tolerate a restart. To make Spot work well:

  1. Diversify. Allow many instance types and zones, so that a shortage in one pool does not stop you. Auto Scaling groups with mixed instances policies do this for you (see Auto Scaling Groups).
  2. Handle the notice. Watch for the interruption warning, finish or hand off work, and deregister from load balancers.
  3. Checkpoint. Save progress regularly to S3 or a queue so a replacement instance can continue.

Capacity Reservations

When a popular instance type is short in a zone, an On-Demand launch can fail with "insufficient capacity". An On-Demand Capacity Reservation holds a number of instances for you in one zone. You pay the On-Demand price for them whether you run them or not, and you can cancel any time. It guarantees availability, not a lower price. Savings Plans can be applied on top of the reserved capacity to get the discount, too.

How to think about the choice

A good strategy has layers:

flowchart TB
    S["Spot<br/>flexible, interruptible work"] --- O["On-Demand<br/>the unpredictable peak"]
    O --- P["Savings Plans / Reserved<br/>the steady baseline you are sure about"]

Cover the steady floor with commitments, the peaks with On-Demand, and the fault-tolerant extras with Spot.

The rule of thumb for a commitment is a break-even: if a plan gives you a discount of d (for example 30%), it only wins when the instance would run more than (1 - d) of the time (70%). Below that, the hours you pay for but do not use cost more than the discount saves.

The first calculator uses invented rates. The On-Demand price is $0.10 per hour, a one-year plan gives a 30% discount and a three-year plan a 50% discount, and Spot gives a 70% discount. It computes the monthly cost of one instance for several utilization levels, where the commitment is paid for the whole month (730 hours) no matter how much you run.

Python Break-even between On-Demand and a commitment

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

At 20% utilization (146 hours) both commitments are much worse than just paying On-Demand. At 100% they win by the full discount. That is why the baseline you commit to should be the usage you will have all the time, and not the average.

Spot interruptions and checkpoints

Spot is cheap per hour, but interrupted work has to be redone. The second stand-in runs a 20-hour job on Spot where each hour has an 8% chance of an interruption, using a simple fixed pseudo-random sequence so that the output is always the same. It compares a job that must restart from zero with a job that checkpoints every hour (and so loses only the interrupted hour). Prices are again invented: On-Demand $0.10 per hour and Spot $0.03.

Python Spot with and without checkpoints

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Look at the two columns. Seed 1 is lucky and has no interruptions, so Spot costs $0.60 against $2.00 On-Demand. With checkpointing, seeds 2 and 3 need the 20 hours plus one redone hour per interruption (25 and 21 hours), so Spot still costs a fraction of On-Demand. Without checkpoints, seeds 2 and 3 throw away so much work that Spot ends up more expensive than On-Demand ($2.52 and $3.33), and on a longer job restarting from zero may never finish at all. The savings number on the price list only holds for software that tolerates the interruptions.

Spot in practice: notices, fleets and allocation strategies

The interruption notice

Two signals tell your software to get ready:

  • The interruption notice, about two minutes before the instance is reclaimed. Your code can poll the instance metadata path spot/instance-action, which returns 404 until a notice exists, then a small JSON document with the action and time. The same event is sent to EventBridge as EC2 Spot Instance Interruption Warning.
  • The rebalance recommendation, an earlier, softer signal that the instance has an elevated risk of interruption. It is not a guarantee, and it may arrive long before the notice (or not at all). You can use it to start a replacement and move work early.

Polling the metadata service with IMDSv2 (read-only, run on the instance):

Terminal
TOKEN=$(curl -s -X PUT "http://169.254.169.254/latest/api/token" \
  -H "X-aws-ec2-metadata-token-ttl-seconds: 60")

curl -s -H "X-aws-ec2-metadata-token: $TOKEN" \
  http://169.254.169.254/latest/meta-data/spot/instance-action
# 404 normally; when interrupted:
# {"action": "terminate", "time": "2026-11-10T09:12:00Z"}

What happens to the instance is the interruption behavior, which you choose when you request the instance: terminate (the default), stop (an EBS-backed instance keeps its volume and can start again when capacity returns), or hibernate.

This simulator shows a worker that checks the notice every five seconds and uses the two minutes to checkpoint and deregister. The "metadata service" is a stand-in function.

Python Reacting to a Spot interruption notice

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

EC2 Fleet and Spot Fleet

Asking for one instance type in one zone is the most fragile way to use Spot. A fleet request describes the capacity you want and lets EC2 choose from many pools:

  • EC2 Fleet is the modern API. You give a launch template with several instance-type overrides, a target capacity (instances or vCPUs), and how much should be On-Demand and how much Spot. The request type can be instant (one synchronous call), request or maintain (EC2 replaces interrupted instances to keep the target).
  • Spot Fleet is the older, Spot-focused API with similar ideas. New designs usually prefer EC2 Fleet or an Auto Scaling group with a mixed instances policy, which adds health checks and scaling policies (see Auto Scaling).

A capacity pool is one instance type in one zone. The more pools a fleet may use, the better its odds. The allocation strategy decides how it picks:

Strategy Chooses pools by Comment
price-capacity-optimized Lowest price among the pools with the most spare capacity The recommended default for most workloads
capacity-optimized The deepest spare capacity, ignoring price Lowest interruption rates, good for costly-to-interrupt work
lowest-price Cheapest pools, regardless of capacity Cheapest at first sight, but higher interruption risk
diversified Spreads evenly across all pools Spreads risk, not tuned for price

The stand-in compares strategies with invented prices and interruption chances per pool. It shows how "cheapest" can lose.

Python Allocation strategies and expected cost

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Good fleet hygiene: allow many instance types (at least ten if the software permits), use all zones in the Region, prefer newer generations, and keep an On-Demand base for the part that must not be interrupted. You can check how likely a request is to succeed with a Spot placement score, a console and API tool that rates a Region or zone for the capacity you want.

Estimating cost with the AWS Pricing Calculator

Before you launch, estimate. The AWS Pricing Calculator (a free web tool) builds a monthly estimate from the services, quantities and options you choose, for example 4 m6i.large instances, Linux, 70% utilized, with a 1-year Compute Savings Plan, 200 GB of gp3 and 500 GB of transfer. Then:

  1. Add each service as an estimate line, and set the Region, because prices differ.
  2. Choose the purchasing model per line (On-Demand, Savings Plan, Spot is not modelled the same way, so use the Spot price history for Spot).
  3. Add the surrounding costs: EBS, load balancers, NAT gateways, public IPv4 addresses and data transfer. Beginners usually forget these.
  4. Export or share the estimate, so that finance and engineers can look at the same numbers.

For Spot, look at the Spot Instance advisor, which shows the typical savings and interruption frequency range of each instance type, and at the Spot price history in the console. Use the calculator for a plan and Cost Explorer to compare it with reality afterward.

Practical advice

  • Start On-Demand, measure for a few weeks, then commit to the stable floor. The Cost Explorer commitment recommendations help you size it (see Cost Management and Optimization).
  • Prefer Compute Savings Plans when you are unsure of the exact instance mix, and a smaller commitment over a larger one: you can always add another plan.
  • Use Spot for the elastic part of a fleet, not for everything.
  • Right-size first. Committing to an oversized instance locks in waste. Switching to a smaller type, or to Graviton instances, is a discount that needs no commitment.
  • Turn off what you do not use, such as dev servers at night. No plan beats a stopped instance.

Check your understanding

Quick check ยท 5 questions

of 5 answered You scored / 5 ยท perfect!

  1. 1. What is the main risk of a Savings Plan?

    The commitment is billed every hour for the whole term. Usage above the commitment is billed On-Demand, so you can still grow.
  2. 2. Which workload is best suited to Spot Instances?

    Spot can be taken back at short notice, so it fits interruptible and retryable work. Stateful, single-instance services are a poor match.
  3. 3. What does an On-Demand Capacity Reservation provide?

    It guarantees that instances of the chosen type can be launched in that zone. It does not lower the price unless a Savings Plan or Reserved Instance covers the usage.
  4. 4. A plan gives a 40% discount. Roughly how much of the time must the instance run for the plan to beat On-Demand?

    Break-even utilization is 1 minus the discount, so 60%. Below that, the unused committed hours cost more than the discount saves.
  5. 5. How much warning does AWS give before interrupting a Spot Instance?

    A two-minute notice is delivered through instance metadata and EventBridge, which is enough to checkpoint and drain connections but not to finish long work.

Summary

  • On-Demand has no commitment and no discount. Savings Plans and Reserved Instances trade a one- or three-year commitment for a lower rate. Spot trades interruptibility for the deepest discount. Capacity Reservations guarantee capacity, not price.
  • A commitment pays off only above a break-even utilization of one minus the discount, so commit to the steady floor, not the average.
  • Compute Savings Plans are the flexible default. EC2 Instance Savings Plans give more discount for less flexibility.
  • Spot needs diversification, handling the two-minute notice and checkpoints.
  • Right-size and switch off unused instances before buying commitments.

Next: Connecting to Instances and Security Groups