Sub topic 2
Regional vs Zonal RIs, Savings Plans, and Spot Instances
Assume you know EC2 instance families, Availability Zones, Regions, and basic AWS billing. The key choice is how much capacity stability and workload flexibility you need.
Regional and zonal Reserved Instances
A Reserved Instance (RI) is a billing discount for committing to an EC2 configuration for one or three years.
A regional RI applies its discount to matching usage anywhere in a Region. You can move instances between Availability Zones without losing the billing benefit. Regional RIs are useful when your workload may change zones.
A zonal RI applies to one Availability Zone. In exchange, it can reserve physical capacity there. This helps when launching an instance is more important than keeping placement flexible.
| Scope | Billing discount | Capacity reservation | Best fit |
|---|---|---|---|
| Regional | Across the Region | No | Flexible placement |
| Zonal | One Availability Zone | Yes | Capacity-sensitive workloads |
Savings Plans: an hourly spend commitment
A Savings Plan commits you to a steady amount of eligible compute spend per hour, such as $2 per hour, for one or three years. AWS applies discounted rates to eligible usage up to that commitment. Usage above it is billed at On-Demand rates.
Unlike a zonal RI, a Savings Plan does not reserve EC2 capacity.
aws ce get-savings-plans-purchase-recommendation \
--savings-plans-type COMPUTE_SP \
--term-in-years ONE_YEAR \
--payment-option NO_UPFRONT \
--lookback-period-in-days THIRTY_DAYSCompute versus EC2 Instance Savings Plans
A Compute Savings Plan provides the most flexibility. It can apply across instance families, Regions, operating systems, and supported compute services.
An EC2 Instance Savings Plan offers a larger discount, but commits you to an EC2 instance family in a Region. It can usually accommodate different sizes within that family, but it does not reserve capacity.
Choose the broader plan when your architecture may change. Choose the narrower plan when usage is stable and predictable.
Spot Instances and interruptions
Spot Instances use spare EC2 capacity at a discount. AWS can reclaim them when it needs the capacity or when market conditions change. They fit interruption-tolerant work such as batch jobs, stateless workers, and checkpointed processing.
AWS usually gives a two-minute interruption notice. Poll the instance metadata service and drain work before termination.
TOKEN=$(curl -s -X PUT "http://169.254.169.254/latest/api/token" \
-H "X-aws-ec2-metadata-token-ttl-seconds: 300")
curl -s -H "X-aws-ec2-metadata-token: $TOKEN" \
http://169.254.169.254/latest/meta-data/spot/instance-actionExercise
A batch worker can restart from checkpoints and runs across several instance types. Which pricing model is a good starting point?
Show answer
Spot Instances, with diversified instance types and replacement logic.