All posts
Cost

Spot vs On-Demand: when the math works

October 29, 20268 min read

AWS advertises Spot discounts of up to 90% off On-Demand. That number is real and almost useless, because the decision is not "which instance costs less per hour." Spot always does. The decision is which option costs less per unit of finished work, after you account for interruptions, retries and the engineering needed to survive them.

This post gives you the break-even math, shows it with real list prices, and then covers where Spot works, where it does not, and the mistakes that turn a 65% discount into a surprise bill.

The only formula you need

A Spot instance can be reclaimed with two minutes of notice. When that happens, some work is lost and has to be redone. Call the fraction of extra work caused by interruptions r (rework). Then:

effective Spot cost = Spot price x (1 + r) Spot wins when: Spot price x (1 + r) < On-Demand price

Written as a discount d (a 65% discount means d = 0.65), the break-even rework is:

break-even r = 1 / (1 - d) - 1

That gives you a feel for how much interruption you can afford:

  • 30% discount: Spot only wins while rework stays under about 43%.
  • 50% discount: rework can reach 100%. You can do every job twice and break even.
  • 65% discount: rework can reach about 186%.
  • 80% discount: rework can reach 400%.

The takeaway: with a typical Spot discount, even sloppy interruption handling usually still wins on pure compute cost. The real risk is not the compute math. It is the workloads where an interruption has a cost beyond lost minutes: a failed customer request, a corrupted state, a missed deadline.

A worked example with real prices

The On-Demand list price for an m5.xlarge (4 vCPU, 16 GiB) in us-east-1 on Linux is $0.192 per hour. Take a batch fleet of 20 of them running 12 hours a day for 30 days: 7,200 instance-hours.

  • On-Demand: 7,200 x $0.192 = $1,382.40 a month.
  • Spot at a 65% discount ($0.0672/hr): 7,200 x $0.0672 = $483.84 a month.
  • Spot with 15% rework from interruptions: 8,280 hours x $0.0672 = $556.42 a month, still about 60% cheaper.

The 65% figure is an assumption for illustration. Actual Spot prices differ by instance type, availability zone and time, so check the Spot price history and the Spot Instance Advisor for the pools you intend to use before you plan around a number.

Where Spot works

  • Stateless or queue-driven workers. If a worker dies, another picks up the message. This is the easiest win.
  • CI/CD runners and build fleets. A failed build reruns. Developers rarely notice.
  • Batch, ETL and data processing. Especially task nodes in Spark or EMR clusters where the core nodes hold the data.
  • ML training with checkpointing. Save progress every few minutes and an interruption costs you minutes, not hours.
  • Kubernetes worker nodes for fault-tolerant services. Replicated stateless pods tolerate losing a node. See what Cluster Autoscaler gets wrong for how node provisioning interacts with this.
  • Dev, test and load-testing environments. Nobody is harmed if they vanish.

Where it does not

  • Single-instance stateful systems such as a lone database or a legacy app with local state and no checkpoints.
  • Latency-critical request paths with no spare capacity. A two-minute warning does not help if your whole tier is on one instance type in one zone.
  • Long jobs that cannot checkpoint. A 20-hour job with no saved progress, on a pool that interrupts regularly, may never finish.
  • Per-instance licensing or compliance setups where replacing an instance is expensive or slow.
  • Workloads already covered by commitments. If a Savings Plan or reservation already covers the baseline, that spend is sunk. Moving covered usage to Spot leaves the commitment paying for nothing, and you only come out ahead if the freed commitment gets used by other On-Demand work.

How interruptions actually work

Spot capacity is spare EC2 capacity, so AWS can take it back when it needs it. You pay the Spot price in effect, not a bid you set, and prices move gradually with long-term supply and demand rather than spiking the way they did years ago.

  • Two-minute notice. Delivered through the instance metadata service and as an EventBridge event. Enough time to drain connections and save a checkpoint if you have code listening for it.
  • Rebalance recommendation. An earlier signal that an instance is at elevated risk. Capacity Rebalancing in Auto Scaling groups can use it to launch a replacement before the interruption.
  • Interruption frequency varies by pool. The Spot Instance Advisor groups instance types into bands from under 5% to over 20% interruptions per month. Newer or less popular types often interrupt less than the obvious choice.

Making Spot boring

  1. Diversify. Allow many instance types, sizes and availability zones. A fleet that accepts ten different pools almost never loses all of them at once. A fleet pinned to one type is the one that gets hurt.
  2. Pick the right allocation strategy. The price-capacity-optimized strategy favors pools with deep spare capacity at low prices, which tends to mean fewer interruptions than choosing purely on price.
  3. Keep an On-Demand base. A mixed-instances Auto Scaling group can hold a small On-Demand floor for the capacity you cannot lose and put the rest on Spot.
  4. Checkpoint. Make the cost of an interruption minutes by saving state on a schedule and on the two-minute warning.
  5. Handle the notice. Deregister from the load balancer, finish or hand off in-flight work, flush buffers.

The traps that erase the savings

Silent fallback to On-Demand. The most expensive Spot mistake is not an interruption, it is a workload that stops using Spot without anyone deciding to. Someone edits a launch template, removes the Spot market option, or a capacity shortage makes a fleet fall back to On-Demand. Nothing breaks. The job just costs three times as much, every night, until the invoice arrives. We covered this pattern in My AWS bill spiked overnight.

Orphaned volumes and addresses. When an instance is reclaimed, EBS volumes that were not set to delete on termination keep billing. A fleet that churns through hundreds of instances a day can leave a long tail of unattached volumes.

Unaccounted rework. If jobs restart from zero after every interruption, your real r may be far higher than you assumed. Measure how often jobs restart and how much work is lost, rather than trusting the discount.

Everything pinned to one pool. One instance type in one zone makes every interruption a full outage and pushes your effective r toward the break-even line.

Check the numbers every quarter

Spot economics shift. New instance generations arrive, discounts in your pools move, and your own workloads change. A short review is enough:

  1. For each Spot workload, compare actual cost per unit of work (per job, per build, per training run) against what On-Demand would have cost.
  2. Check the interruption rate and the share of work that restarts.
  3. Confirm the workload is still launching as Spot and has not drifted to On-Demand.
  4. Look for stateless On-Demand workloads that could move.

SpikeCatcher watches CloudTrail for EC2 launches in real time and tracks cost velocity per service, so a Spot workload that quietly turns into On-Demand, or a fleet that suddenly runs many times its normal size, shows up as a cost-rate spike within minutes instead of on next month's invoice. Alerts fire in under 15 minutes. 14-day free trial, 5-min setup, read-only IAM.

aws-costsec2spot-instancesfinops

Protect your AWS account — 14-day free trial

Real-time threat and cost anomaly detection. Detects credential theft, cryptomining, and runaway costs in under 15 minutes. 5-minute setup via CloudFormation.

No credit card. Cancel anytime.