Course outline

4.4

Purchasing Options: On-Demand to Spot

On-Demand, Reserved, Savings Plans, Spot and Spot Fleet, Dedicated Hosts and Instances, Capacity Reservations, and how to choose.

30 min Reading + animations

Tip: tap or hover any dotted-underlined term to see what it means.

By the end of this lesson you will be able to

  • Explain how On-Demand, Reserved Instances, Savings Plans, Spot, Dedicated Hosts, Dedicated Instances and Capacity Reservations are billed, and what each one promises.
  • Choose between Standard and Convertible Reserved Instances, the payment options, and Regional vs zonal scope.
  • Pick the right Savings Plan (Compute, EC2 Instance, SageMaker AI, Database) and size the hourly commitment.
  • Run Spot Instances safely: handle the rebalance recommendation and the two-minute notice, choose the interruption behaviour, and cancel a persistent request the right way.
  • Choose a Spot Fleet or EC2 Fleet allocation strategy and explain why price-capacity-optimized is the default advice.
  • Combine several options in one architecture, and answer the classic exam keywords (steady state, fault-tolerant, BYOL, capacity assurance).

#Same server, different prices

An m7i.large in one Region is the same virtual machine whichever way you pay for it. What changes is the deal you strike with AWS:

  • How long you promise to keep using it (nothing, 1 year, 3 years).
  • How much you pay before you start (nothing, part, everything).
  • Whether AWS may take the server back (Spot) or must keep room for you (Capacity Reservations).
  • Whether the physical machine is shared with other customers (default tenancy) or only yours (Dedicated).

The more certainty you give AWS, and the more risk you accept, the lower your price. Seven options come out of those four questions:

OptionCommitmentDiscount vs On-DemandCan AWS take it back?Typical use
On-DemandNoneNone (the reference price)NoShort, unpredictable or must-not-stop work
Reserved Instances1 or 3 years, one instance configurationUp to about 72%NoSteady, known workloads (a database server)
Savings Plans1 or 3 years, a dollar amount per hourUp to about 72%NoSteady spend that may change shape
Spot InstancesNoneUp to about 90%Yes, with a two-minute noticeFault-tolerant, flexible jobs
Dedicated HostsNone, or a 1/3-year host reservationReservation availableNoSocket/core-based licences (BYOL), placement control
Dedicated InstancesNoneNone by themselvesNoHardware not shared with other accounts
Capacity ReservationsNone (cancel any time)None by themselvesNoGuaranteed room in one Availability Zone

#On-Demand: pay as you go

On-Demand is what you get when you launch an instance and choose nothing else.

  • Billing: per second, with a 60-second minimum, for Linux, Windows (including Windows with SQL Server), Red Hat Enterprise Linux (RHEL) and Ubuntu Pro. A few other operating systems, mostly commercial Linux distributions with their own licence fee, are still billed per full hour.
  • You pay only while the instance is running. A stopped instance costs nothing for compute, but its EBS volumes are still billed.
  • No upfront payment, no commitment, and the highest price per hour.
  • Best for short-term, spiky or unpredictable workloads, for new applications whose behaviour you do not know yet, for development and testing, and for work that cannot be interrupted but does not run long enough to justify a commitment.

#Reserved Instances (RI)

A Reserved Instance is not a server. It is a billing discount that AWS applies automatically, every hour, to running instances that match it. You buy it for:

  • an instance type (for example m7i.large), a platform (Linux, Windows…), a tenancy (default or dedicated) and a Region (plus an Availability Zone if it is zonal);
  • a term of exactly 1 year or 3 years (3 years gives the bigger discount);
  • a payment option: No Upfront, Partial Upfront or All Upfront (the more you pay at the start, the lower the total).

If no matching instance runs in a given hour, that hour of the reservation is simply wasted. You pay for the whole term either way.

#Standard vs Convertible

Standard RIConvertible RI
DiscountBiggest, up to about 72%Smaller, up to about 66%
Change Availability Zone, scope, size within the familyYes (modify)Yes (modify)
Change instance family, OS, tenancyNoYes, by exchanging it for another Convertible RI of equal or higher value
Sell on the RI MarketplaceYesNo

Choose Standard when you are sure what you will run for the whole term, Convertible when you want the commitment discount but expect to change instance families (for example, moving to a newer generation or to Graviton).

#Regional vs zonal scope

Regional RIZonal RI
Discount applies inAny Availability Zone of the RegionOne Availability Zone
Instance size flexibilityYes for Linux/Unix with default tenancy: an m7i.xlarge reservation also covers two m7i.large, or half of an m7i.2xlargeNo: exact type only
Capacity reservationNoYes: AWS keeps room for that instance in that zone

So a zonal RI is a discount and a capacity promise in one zone; a Regional RI is a more flexible discount with no capacity promise.

#The Reserved Instance Marketplace

If your plans change, you can sell unused Standard RIs to other customers on the Reserved Instance Marketplace, and you can buy someone else’s leftover term there (often shorter than 1 year). The rules worth knowing: only Standard RIs can be sold (never Convertible), you must have owned the RI for at least 30 days, at least one month of the term must remain, and AWS keeps a service fee from the sale.

#Savings Plans

A Savings Plan is a commitment to spend a fixed amount of money per hour (for example “$10 per hour of compute”) for 1 or 3 years. Every hour:

  1. AWS applies your discounted rates to eligible usage until the hour’s commitment is used up.
  2. Usage above the commitment is billed at normal On-Demand rates.
  3. Commitment not used in that hour is lost: you pay the full hourly amount even if you ran nothing.

Payment options are the same as RIs: No, Partial or All Upfront (Database Savings Plans are the exception, see below). A Savings Plan cannot be sold or cancelled, and it never reserves capacity.

Savings PlanApplies toLocked toMax discount
ComputeEC2 (any family, size, Region, OS, tenancy), Fargate and LambdaNothing but the dollar amountUp to about 66%
EC2 InstanceEC2 in one instance family in one Region (for example M7i in us-east-1)Family + Region; free to change size, OS, tenancy, Availability ZoneUp to about 72%
SageMaker AISageMaker AI instance usage (training, inference, notebooks…)SageMaker AI onlyUp to about 64%
DatabaseManaged databases such as Aurora, DynamoDB and ElastiCacheDatabase services only; 1-year term, no upfrontUp to about 35%

The trade-off is the same as for RIs: more flexibility, smaller discount. A Compute Savings Plan follows you if you move from x86 to Graviton, from EC2 to Fargate or from one Region to another; an EC2 Instance Savings Plan gives a few points more discount but stays with one family in one Region.

#Spot Instances

Spot Instances use spare EC2 capacity that nobody is paying full price for right now. Because AWS can take it back when On-Demand customers need it, it is sold at up to about 90% off the On-Demand price.

#How the Spot price is set

#Interruptions: the two signals

AWS interrupts a Spot Instance mostly because it needs the capacity back, much more rarely because the price rose above your maximum. Before it happens you may get two signals, both readable from instance metadata and both published as EventBridge events:

  1. Rebalance recommendation: “this instance is now at elevated risk.” It often arrives earlier than the interruption notice, but it is not guaranteed. Auto Scaling groups and EC2 Fleet can react with Capacity Rebalancing: launch a replacement first, then drain the old instance.
  2. Interruption notice: sent two minutes before AWS stops or terminates the instance. With the hibernate behaviour the notice is sent too, but hibernation starts at once, with no two-minute grace.

Both signals are sent on a best-effort basis, so AWS suggests checking instance metadata every few seconds, and the design must still survive an instance that vanishes without warning. Two minutes is enough to finish a request, save a checkpoint or deregister from a load balancer. It is not enough to finish an hour-long job, which is why Spot workloads must be able to resume or retry.

#Interruption behaviour: terminate, stop or hibernate

BehaviourWhat happensRequirements
Terminate (default)Instance and its instance store are gone; EBS volumes follow their delete-on-termination settingNone
StopInstance stops, EBS volumes are kept (and billed); EC2 restarts it itself when capacity returns in the same zone for the same typePersistent request (or a fleet of type maintain), EBS root volume
HibernateStarts as soon as the notice is sent: memory is saved to the encrypted EBS root volume, then the instance stops; it resumes where it left offSame as stop, plus the usual hibernation prerequisites (lesson 4.5)

A Spot interruption, step by step

An image-processing worker runs on a Spot Instance. AWS needs the capacity back. What survives depends on what the job did with its warnings, and on the interruption behaviour you chose.

Scenario

Amazon EC2Spot capacity
EventBridgeSpot events
Spot instanceimage workerrunning
CheckpointsS3 bucket
Replacementfrom another pool
job 70% done
Step 1 of 7
1

The worker has processed 70% of a large batch. It saves its progress to S3 every few minutes, so no more than a few minutes of work are ever at risk.

#One-time vs persistent requests

Every Spot Instance comes from a Spot request:

  • A one-time request launches the instance once. When the instance is interrupted or terminated, the request is closed and nothing comes back.
  • A persistent request stays open for as long as it is valid. If the instance is interrupted, or you terminate it, the request launches (or restarts) another one.

Spot requests: who keeps launching instances

A Spot Instance always comes from a Spot request. A persistent request keeps working until you cancel it, which is why the order of cancel and terminate matters.

Scenario

You
Spot requestone-time or persistentopen
Amazon EC2
Spot instance
create: persistent
Step 1 of 5
1

You create a persistent Spot request for one instance. Persistent means: keep one instance running for as long as this request is open.

#What Spot is good for

The keywords from the exam are worth memorising: fault-tolerant, flexible start and end times, batch jobs, data analysis, image or media processing, build and test agents, stateless web servers behind a load balancer, big data and container clusters. If the job can stop and start again without losing anything important, it can run on Spot.

The owner’s notes give a classic scenario line: “an application performing big data analysis on a fleet of EC2 instances”. When the last line asks for the cheapest way to run that fleet, the answer is Spot Instances / Spot Fleet: the analysis is a batch job, and if one or two servers disappear mid-way another one simply redoes their part. (The same scenario also asks about placement, instance type and storage; those answers are in lessons 4.1, 4.5 and the EC2 storage chapter.)

Self-checkQuestion

A nightly job converts uploaded photos into thumbnails. It can run any time before morning, and a half-finished photo can simply be converted again. Which purchasing option is the most cost-effective?

#Spot Fleet and EC2 Fleet

Asking for one instance type in one zone is the riskiest way to use Spot: if that pool runs short, every instance you have goes at once. A fleet asks for a target capacity (a number of instances, or of virtual CPUs or memory) and gives AWS a list of acceptable launch pools: several instance types across several Availability Zones. It can also mix in On-Demand instances as a guaranteed base. The fleet keeps launching until it reaches the target capacity or your maximum total price, and with type maintain it replaces interrupted instances.

The allocation strategy decides which pools the Spot part uses:

StrategyPicksGood forRisk
price-capacity-optimizedPools with the most spare capacity, and among those the cheapestRecommended for most workloadsLow interruption, low price
capacity-optimizedPools with the most spare capacity, ignoring priceExpensive-to-interrupt work (long jobs, big clusters)Lowest interruption, may cost a little more
lowest-priceThe cheapest pool(s) onlyVery short jobs where price is everythingHighest interruption: cheap pools are cheap because they are nearly full
diversifiedSpread evenly across all poolsLong-running fleets that must keep most capacityLosing one pool only removes a share

One fleet, six Spot pools

A fleet needs 12 instances and may use six pools (instance type + Availability Zone). The allocation strategy decides where they go, and so how much one reclaimed pool can hurt.

Scenario

us-east-1
us-east-1a
us-east-1b
us-east-1c
EC2 Fleettarget: 12
m7i.large× 12
c7i.large× 0
m7i.large× 0
m6i.large× 0
m6i.large× 0
r7i.large× 0
× 12

Spot pools (instance type · Availability Zone)

PoolPriceSpare capacityInstances
m7i.large · a★ lowestvery low12
c7i.large · alowhigh0
m7i.large · bmediumvery high0
m6i.large · blowvery high0
m6i.large · cmediumhigh0
r7i.large · chighmedium0
Step 1 of 3
1

lowest-price looks only at price. Pool 1 is the cheapest, so all 12 instances go there.

#Dedicated Hosts and Dedicated Instances

Normal instances, whatever you pay, use shared tenancy: your virtual machine is one slice of a large physical server, and other customers’ machines may run beside it. You never learn how many physical sockets or cores that server has.

That is a problem for some enterprise software. Vendors such as Oracle or Microsoft (Windows Server, SQL Server) may license by physical socket or physical core, not by virtual CPU. To bring your own licence (BYOL) you must be able to see and count that hardware. The owner’s notes call this one of the most common and trickiest exam questions:

A vendor licence for a database bills by physical cores and socket visibility. Which purchasing option gives that visibility? → Dedicated Hosts.

Dedicated InstanceDedicated Host
HardwareNot shared with other accounts (may share with your own account’s other instances)A whole physical server for you
See sockets and physical coresNoYes
Control which host an instance lands on, host affinityNo (after a stop/start it may move to other hardware)Yes
Server-bound licences (BYOL per socket/core)NoYes
BillingPer instance, plus a per-Region dedicated feePer host, however many instances you run on it
DiscountsRIs and Savings Plans with dedicated tenancyOn-Demand per host, Dedicated Host Reservation (1 or 3 years), Savings Plans
Choose whenCompliance says “no shared hardware”Licences, sockets/cores, placement control, strict compliance

Dedicated Hosts are the most expensive way to run EC2, so they only make sense when licensing or compliance demands them.

#On-Demand Capacity Reservations (ODCR)

A Capacity Reservation keeps room for a number of instances of one type, platform and tenancy in one Availability Zone, starting now (or on a future date) and lasting as long as you want:

  • No term: create it, cancel it any time (future-dated reservations carry a minimum commitment period you choose when you book).
  • Charged at the On-Demand rate whether you run instances in it or not: an empty reservation costs exactly as much as a full one.
  • No discount by itself. To lower the price, combine it with Regional Reserved Instances or Savings Plans: their discount applies to the instances in the reservation.
  • Instances use it automatically (open matching) or only when they name it (targeted matching).
Capacity ReservationZonal Reserved Instance
Capacity in one zoneYesYes
Billing discountNo (add a Regional RI or Savings Plan)Yes
TermNone, cancel any time1 or 3 years
Good forA launch, a sale event, disaster-recovery capacity, regulated workloads that must start in a given zoneSteady workloads that need both the discount and the capacity

For short-term GPU needs (training a model for a few days), EC2 Capacity Blocks reserve GPU instances for a set period, paid in advance.

#How to choose

If the question says…Choose
Short-term, unpredictable, cannot be interrupted, new appOn-Demand
Steady state, predictable, runs 24/7 for years (a database)Reserved Instances (Standard for the biggest discount) or an EC2 Instance Savings Plan
Long-term but may change family, Region, or move to Fargate/LambdaCompute Savings Plan (or Convertible RI)
Fault-tolerant, flexible start and end, batch, analysis, image processingSpot (with a fleet across many pools)
Licences per socket/core, BYOL, placement controlDedicated Hosts
No hardware shared with other customers, nothing elseDedicated Instances
Must be able to launch in one Availability Zone at a given timeCapacity Reservation (+ Savings Plan or Regional RI for the discount)

#Mixing options in one architecture

Real systems combine several options. A typical online shop:

  • Web tier in an Auto Scaling group: a few On-Demand instances as the always-on base, covered by a Compute Savings Plan; extra instances for busy hours on Spot, spread over many instance types with price-capacity-optimized. If a Spot instance is interrupted, the load balancer simply sends traffic to the others.
  • Database: never Spot. On EC2, a 3-year Reserved Instance; on a managed service, its own reservations or a Database Savings Plan.
  • Nightly reports and image processing: Spot, with checkpoints to S3.
  • A big sale day: Capacity Reservations in two Availability Zones for that week, discounted by the existing Savings Plan.
  • A licensed commercial database billed per core: a Dedicated Host.

The rule of thumb: commit to the baseline, use Spot for what can be interrupted, pay On-Demand for the rest.

Commit to what, exactly?

A workload runs a steady baseline all year plus extra instances for a few hours a day. Change the shape and see what a year costs under four plans, as a percentage of running everything On-Demand.

Baseline, 24/7
Extra at peak
Peak hours a day
Savings Plan term
Peak work can be interrupted
  • Everything On-Demand100%
  • Commit to the peak128%
  • Commit to the baseline, peak On-Demand65%
  • ★ Commit to the baseline, peak on Spot44%
commitment usedcommitment wastedOn-DemandSpot

Illustrative rates: Savings Plan ≈ 32% off for 1 year or ≈ 52% off for 3 years, Spot ≈ 65% off. Real discounts depend on instance type, Region, term and payment option.

i

Commit only to what runs every hour, and put the interruptible peak on Spot. Committing to the peak pays for idle instances most of the day (the red part).

Self-checkQuestion

An online shop runs these four parts. Which one should NOT run on Spot Instances?

#Try it yourself

# 1. Recent Spot prices for one instance type in every AZ of the Region
aws ec2 describe-spot-price-history \
  --instance-types m7i.large \
  --product-descriptions "Linux/UNIX" \
  --start-time "$(date -u -d '-1 day' +%Y-%m-%dT%H:%M:%S)" \
  --query 'SpotPriceHistory[].[AvailabilityZone,SpotPrice,Timestamp]' --output table

# 2. Launch one Spot instance from a persistent request that stops (not terminates) when interrupted
aws ec2 run-instances \
  --image-id ami-0123456789abcdef0 --instance-type m7i.large --count 1 \
  --instance-market-options '{"MarketType":"spot","SpotOptions":{"SpotInstanceType":"persistent","InstanceInterruptionBehavior":"stop"}}'

# 3. Find the request behind the instance, then CANCEL THE REQUEST FIRST, then terminate
SIR=$(aws ec2 describe-instances --instance-ids i-0abc1234def567890 \
  --query 'Reservations[0].Instances[0].SpotInstanceRequestId' --output text)
aws ec2 cancel-spot-instance-requests --spot-instance-request-ids "$SIR"
aws ec2 terminate-instances --instance-ids i-0abc1234def567890

# 4. Compare 1-year Standard RI offerings (31536000 seconds = 1 year)
aws ec2 describe-reserved-instances-offerings \
  --instance-type m7i.large --product-description "Linux/UNIX" \
  --offering-class standard --instance-tenancy default \
  --min-duration 31536000 --max-duration 31536000 \
  --query 'ReservedInstancesOfferings[].[OfferingType,Scope,FixedPrice,RecurringCharges[0].Amount]' --output table

# 5. Reserve capacity for two instances in one AZ (billed at On-Demand rate until cancelled)
CR=$(aws ec2 create-capacity-reservation \
  --instance-type m7i.large --instance-platform Linux/UNIX \
  --availability-zone us-east-1a --instance-count 2 \
  --instance-match-criteria open --query 'CapacityReservation.CapacityReservationId' --output text)
aws ec2 cancel-capacity-reservation --capacity-reservation-id "$CR"   # stop paying for it

In step 2, a persistent request launched by run-instances must use the stop or hibernate behaviour. If you skip step 3’s cancel and only terminate the instance, check the console a minute later: the request launches a new one.

#Summary

Key takeaways

  • On-Demand: no commitment, highest price, per-second billing (60-second minimum) for Linux, Windows, RHEL and Ubuntu Pro; does not guarantee capacity.
  • Reserved Instances: a billing discount for 1 or 3 years on one configuration, up to about 72% (Standard) or 66% (Convertible). No/Partial/All Upfront. Zonal RIs also reserve capacity; Regional RIs give size flexibility but no capacity. Only Standard RIs can be sold on the Marketplace.
  • Savings Plans: commit $/hour for 1 or 3 years; usage above it is On-Demand, unused commitment is lost. Compute (EC2 anywhere + Fargate + Lambda, up to ~66%), EC2 Instance (one family in one Region, up to ~72%), SageMaker AI, Database (1 year, no upfront). No capacity reservation.
  • Spot: spare capacity, up to ~90% off, price set by long-term supply and demand (no bidding). Rebalance recommendation (early, not guaranteed), then a two-minute interruption notice. Terminate (default), stop or hibernate (stop/hibernate need a persistent request). Cancel a persistent request before terminating its instances. Never for databases.
  • Fleets: many pools, optional On-Demand base; price-capacity-optimized is the recommended strategy, lowest-price the riskiest.
  • Dedicated Hosts: a whole server, sockets/cores visible, BYOL, placement control, most expensive. Dedicated Instances: no hardware shared with other accounts, nothing more.
  • Capacity Reservations: capacity in one zone, any duration, full On-Demand price whether used or not; add Savings Plans or Regional RIs for a discount.
  • Commit to the baseline, Spot for the interruptible part, On-Demand for the rest.