在打印窗口把「目标」选为「另存为 PDF」即可保存,页面已带 awsgood.com 版权水印。 返回原文

www.awsgood.com

Spot Instances vs Reserved Instances: Difference & Real Savings

2026-11-06 AWS Configuration 约 6 分钟

TL;DR

The finished picture: what the bill looks like when this is wired right

Before any CLI, here’s the target state. Your monthly EC2 spend splits into three lanes: a baseline of always-on instances covered by reservations, a burst lane of batch/CI/queue workers on spot, and a small on-demand tail for everything unpredictable. In a healthy month the reservation utilization sits at 95–100% and spot covers 20–40% of total instance hours.

That’s the destination. If your current account has no reservations and everything is on-demand, you’re paying the full hourly rate 24/7 for servers that idle at 8% CPU overnight — I’ve seen that gap run to four figures a month on a modest 30-instance estate.

Before you buy: three numbers that decide the whole thing

Don’t buy an RI off a hunch. Pull 30–90 days of data first.

# 1. What are you actually running, and how steady is it?
aws ec2 describe-instances 
  --filters Name=instance-state-name,Values=running 
  --query "Reservations[].Instances[].InstanceType" 
  --output text | tr 't' 'n' | sort | uniq -c | sort -rn

# 2. Monthly instance hours by type
aws ce get-cost-and-usage 
  --time-period Start=2025-01-01,End=2025-04-01 
  --granularity MONTHLY 
  --metrics UsageQuantity 
  --filter '{"Dimensions":{"Key":"USAGE_TYPE_GROUP","Values":["EC2: Running Hours"]}}'


The output of the first command is the only thing that matters: if `m5.large` shows 24 running instances every single day for three months, you have a reservation candidate. If a type fluctuates between 5 and 20, reserve the floor (5) and leave the rest on-demand or spot.

The third number is **normalized units**, which is how AWS compares sizes inside a family. An `m5.large` is 8 units, `m5.xlarge` is 16, `m5.2xlarge` is 32. A regional RI for one `m5.xlarge` will happily cover two `m5.large` in the same family and region — that flexibility is the reason to buy regional RIs instead of zonal ones unless you have a hard AZ pin.

## The difference that actually matters

| | Reserved Instances | Spot Instances |
|---|---|---|
| What you're buying | A billing discount on capacity you already run | Spare EC2 capacity, priced per hour, variable |
| Commitment | 1 year (31536000s) or 3 years (94608000s) | None; per-request, can be terminated anytime |
| Typical discount | ~30–40% (1yr, no upfront) to 60%+ (3yr, all upfront) | Often 60–90% off on-demand; varies by AZ and hour |
| Interruption | None — you own the discount | 2-minute termination notice, then reclaimed |
| Billing when idle | You pay the hourly commitment even if instances are stopped | You pay nothing when there's no spot capacity running |
| Scope | Region + instance family + platform (+ AZ if zonal) | Per instance / ASG / Spot Fleet request |
| Wrong fit for | Spiky, short-lived, or migrating workloads | Databases, stateful queues, anything without checkpointing |

Pricing moves by region and family, so treat those percentages as an order of magnitude and check `describe-reserved-instances-offerings` for the real number in your account.

## Buying the reservation without guessing: CLI walkthrough

Step one is finding the offering ID, which encodes type, duration, payment option and platform.

```bash
aws ec2 describe-reserved-instances-offerings 
  --instance-type m5.large 
  --duration 31536000 
  --offering-class standard 
  --product-description "Linux/UNIX" 
  --offering-type "No Upfront" 
  --query "ReservedInstancesOfferings[].[ReservedInstancesOfferingId,FixedPrice,UsagePrice,AvailabilityZone]" 
  --output table


Parameter meaning, briefly: `--offering-class standard` gives the deepest discount but locks you to the family (convertible trades ~5–10% discount for the right to exchange); `--offering-type` sets cash flow, not total cost — `All Upfront` is cheapest, `No Upfront` costs the most but keeps the cash; omitting `--availability-zone` buys a regional RI, which is the flexible one.

Then purchase:

```bash
aws ec2 purchase-reserved-instances-offering 
  --reserved-instances-offering-id 1a2b3c4d-5e6f-7890-abcd-ef1234567890 
  --instance-count 2


Verification point: the response returns an `ReservedInstancesId`. Confirm it exists and is active before you walk away.

```bash
aws ec2 describe-reserved-instances 
  --filters Name=state,Values=active 
  --query "ReservedInstances[].[InstanceType,AvailabilityZone,InstanceCount,Start,End]" 
  --output table


## Wiring the spot half and proving interruption handling works

For stateless workers, use a mixed-instances ASG policy rather than raw spot requests — it handles diversification and replacement for you.

```json
{
  "MixedInstancesPolicy": {
    "LaunchTemplate": {"LaunchTemplateSpecification": {"LaunchTemplateId": "lt-0123456789abcdef0", "Version": "$Latest"}},
    "InstancesDistribution": {
      "OnDemandBaseCapacity": 1,
      "OnDemandPercentageAboveBaseCapacity": 0,
      "SpotAllocationStrategy": "capacity-optimized"
    }
  }
}


`capacity-optimized` picks pools with the most spare capacity, which measurably cuts interruption rate compared to `lowest-price`. Verification: SSH into a spot worker and confirm the interruption endpoint answers.

```bash
TOKEN=$(curl -sX 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


A 404 means no notice pending — that's the healthy state. A JSON body like `{"action":"terminate","time":"2025-03-11T02:14:00Z"}` means you have 120 seconds. If your app doesn't drain a queue in 120 seconds, spot is the wrong lane for it.

## Verification: coverage, utilization, and the two numbers that are easy to misread

Two weeks after purchase, check both reports.

```bash
aws ce get-reservation-utilization 
  --time-period Start=2025-03-01,End=2025-04-01 
  --granularity MONTHLY


`UtilizationPercentage` under ~95% means you bought more reservation than you run — the discount is being paid for and not used. Then check coverage, which is the opposite question: what share of your eligible hours is discounted.

```bash
aws ce get-reservation-coverage 
  --time-period Start=2025-03-01,End=2025-04-01 
  --granularity MONTHLY 
  --metrics CoverageHoursPercentage


Coverage of 55% with utilization of 99% is fine — that's an estate with a spiky tail. Utilization of 61% is not fine, and it's the number that hides the mistake.

## Three places this breaks — and the one that cost us a year of spend

**You reserve for a family you're about to leave.** Classic. A standard RI for `m5.xlarge` bought in March, fleet moved to `m6i` in June for price-per-core, and the reservation kept billing every hour with zero matching usage. `describe-reserved-instances` still showed `State: active` — the lease doesn't disappear, it just stops helping. We caught it in the RI utilization report dropping to under 10% for two consecutive months. The fix at that point was painful: standard RIs can be listed on the RI Marketplace, but convertible ones can only be exchanged for equal-or-greater value, and exchange value decays with the remaining term. Buying convertible for anything on a migration roadmap is the cheaper insurance.

**You reserve for peak instead of baseline.** Buy 20 reservations because Black Friday hit 20 instances, and you're paying for 14 idle commitments the rest of the year. Reserve the floor, burst the rest.

**You assume the RI covers the whole bill.** It covers instance hours only. EBS volumes, snapshots, NAT gateway data processing and cross-AZ transfer are untouched, and on a small estate those can be 30–40% of the EC2 line. If most of your compute is Lambda or Fargate, an EC2 RI does nothing at all — Compute Savings Plans are the tool there.

One more operational note: stopped instances consume no hours, so a fleet that scales to zero at night will silently waste a reservation. RI utilization is the metric to alert on monthly; when we run this for clients it's usually the first report we open, and it's the kind of check awsgood.com managed services keeps on a schedule so nobody has to remember it.

Start with `describe-reserved-instances-offerings` against your top three instance types by running hours, buy one 1-year no-upfront reservation, and set a calendar reminder for day 30 to read utilization. Scale from there.

Sources