Sub topic 3
Reserved Instances: how they work
This chapter assumes you know what an EC2 instance, an instance family (such as m5 or c5), a Region, and an Availability Zone are. It also assumes you know that On-Demand usage is billed per second or per hour with no commitment. You do not need to have bought a Reserved Instance before.
What you are buying
A Reserved Instance (RI) is a billing commitment, not a server. When you buy one, AWS does not launch anything. You promise to pay for a specific instance configuration for one or three years. In return, AWS lowers the price of matching On-Demand usage in your account. AWS advertises discounts of up to 72% compared with On-Demand, and the real figure depends on the instance, term, and payment option.
This has three consequences:
- You still launch, stop, and terminate instances exactly as before.
- The discount is applied on your bill, not on the instance. The instance does not know it is "reserved".
- You pay for the RI every hour of the term, whether or not a matching instance runs.
The third point is the main risk. An RI that matches nothing is a recurring charge with no benefit.
How AWS matches usage to an RI
Each hour, the billing system looks at the running On-Demand instances in your account. For each one, it checks whether an active RI matches. An RI is defined by these attributes:
| Attribute | Meaning | Example |
|---|---|---|
| Instance type | Family and size | m5.large |
| Region | Where the RI applies | us-east-1 |
| Platform | Operating system and licensing | Linux/UNIX, Windows |
| Tenancy | Shared hardware or dedicated | default |
If a running instance matches, the hour is billed at the RI rate. If it does not match, it is billed at the On-Demand rate. If an RI has no matching instance in a given hour, you still pay for it.
RIs apply only to On-Demand usage. They never discount Spot Instances. They also do not discount usage that a Savings Plan already covers. When both exist, AWS applies RIs first and Savings Plans to the remaining eligible usage.
Instance size flexibility
If an RI had to match exactly, buying 4 m5.large RIs would help only when you run exactly 4 m5.large instances. Instance size flexibility removes that restriction. A Regional RI for Linux/UNIX with default tenancy applies to any size in the same instance family within the Region. Each size has a normalization factor, which is a number of units:
| Size | Units |
|---|---|
| nano | 0.25 |
| micro | 0.5 |
| small | 1 |
| medium | 2 |
| large | 4 |
| xlarge | 8 |
| 2xlarge | 16 |
| 4xlarge | 32 |
| 8xlarge | 64 |
Four m5.large RIs give you 16 units per hour. That covers four m5.large instances, two m5.xlarge instances, or one m5.2xlarge. It also covers a mix such as one m5.xlarge plus two m5.large. The following script does the arithmetic for a case where you run more than you reserved.
FACTORS = {
"nano": 0.25, "micro": 0.5, "small": 1, "medium": 2,
"large": 4, "xlarge": 8, "2xlarge": 16, "4xlarge": 32, "8xlarge": 64,
}
def units(size: str, count: int = 1) -> float:
return FACTORS[size] * count
reserved = units("large", 4) # 4 m5.large RIs
running = units("large", 6) # 6 m5.large instances running
covered = min(reserved, running)
on_demand = running - covered
print(f"Reserved units: {reserved}")
print(f"Running units: {running}")
print(f"Covered by RI: {covered}")
print(f"Billed On-Demand: {on_demand} units "
f"({on_demand / FACTORS['large']} m5.large equivalents)")It prints 16 reserved units, 24 running units, 16 covered, and 8 units billed On-Demand, which is two m5.large equivalents.
Instance size flexibility has limits. It does not apply to:
- RIs tied to a single Availability Zone (zonal RIs).
- Bare metal instances.
- RIs with dedicated tenancy.
- Windows Server, Windows with SQL Server, Red Hat Enterprise Linux (RHEL), and SUSE Linux platforms.
For those cases, the RI matches only the exact instance type you bought.
Sharing across accounts
If your accounts belong to an AWS Organization with consolidated billing, RI discounts are shared across all accounts under the same payer account by default. An RI bought in account A can discount matching usage in account B. This is usually what you want, because unused RIs in one account get used elsewhere. It has side effects:
- The account that owns the RI pays for it, but another account may receive the discount. Chargeback reports must account for this.
- You can turn off RI sharing for an account in the payer's billing preferences. Doing so can lower overall utilization, so do it only for a reason such as strict cost separation.
- The discount follows the matching rules above. Account B's instance must still match the RI's Region, platform, tenancy, and family.
Terms and what you cannot undo
An RI runs for 1 year or 3 years. The next chapter covers term lengths, payment options, and the Standard and Convertible types in depth. What matters here is the shape of the commitment:
- You cannot cancel an RI. The charge continues until the term ends.
- You can modify some attributes of an active RI, such as splitting or merging sizes within a family or changing the Availability Zone of a zonal RI. You cannot change the Region, and you cannot change the term.
- A Standard RI can be listed for sale on the Reserved Instance Marketplace. A later chapter covers that.
The commitment applies to the whole term even if your architecture changes. A team that moves to containers on a different instance family can end up paying for RIs that nothing uses.
Inspecting your RIs with the CLI
You can list active RIs and the attributes that decide matching. The --query option trims the output to the useful fields.
aws ec2 describe-reserved-instances \
--filters Name=state,Values=active \
--query 'ReservedInstances[].{Id:ReservedInstancesId,Type:InstanceType,Count:InstanceCount,Platform:ProductDescription,Scope:Scope,Ends:End}' \
--output tableFor each RI, check the following:
- Type and Count tell you how many units you hold. Convert them using the table above.
- Platform (
ProductDescription) must match what you run. An RI for Windows does not discount Linux. - Scope shows whether the RI is Regional or tied to an Availability Zone. Scope is covered in the chapter on RI scope and capacity.
- Ends shows when the commitment expires. Put these dates in a calendar so that renewals are a decision, not a surprise.
Compare this list with what you actually run, for example with aws ec2 describe-instances. A mismatch in platform or family is the most common reason an RI sits idle.
Common errors
- Buying for peak load. RIs pay off when an instance runs most of the hours in the term. Reserve the steady baseline and leave the variable part On-Demand or Spot.
- Platform mismatch. Buying a Linux RI and running Windows (or the reverse) leaves the RI idle and the instance at full On-Demand price.
- Assuming an RI reserves capacity. A Regional RI gives you a discount only. It does not guarantee that capacity is available when you launch. A zonal RI does reserve capacity. The scope chapter explains the difference.
- Forgetting expiry. When an RI expires, usage silently returns to On-Demand rates. Nothing breaks, but the bill rises.
- Ignoring generation changes. Moving a fleet from m5 to m6i orphans m5 RIs unless they are Convertible or you accept the loss.
- Counting instances instead of units. With size flexibility, compare normalized units, not instance counts.
Where RIs fit
RIs were the first commitment option on AWS, and many accounts still hold them. Savings Plans now cover much of the same ground with more flexibility, so you will often find both in one account. Knowing the matching rules helps you read a bill, decide which RIs to keep as they expire, and see why a given instance was billed at the On-Demand rate.
Exercise
You hold 8 Regional m5.large Linux/UNIX RIs with default tenancy in us-east-1. This hour you run 3 m5.xlarge Linux instances and 2 m5.large Linux instances in that Region, all On-Demand, plus 4 m5.large Spot Instances. How many normalized units are covered by the RIs, and how many units are billed at the On-Demand rate?
Show answer
The RIs provide 8 × 4 = 32 units. The On-Demand usage is 3 × 8 (m5.xlarge) + 2 × 4 (m5.large) = 32 units. The Spot Instances are not eligible for RI discounts, so they are ignored. All 32 units are covered, and 0 units are billed at the On-Demand rate.
Exercise
A team bought 10 Standard RIs for c5.2xlarge Windows in us-east-1. It then moved the workload to Linux on c6i.2xlarge. What happens to the RIs, and why?
Show answer
The RIs stop matching any usage. The platform changed from Windows to Linux, and the family changed from c5 to c6i. Instance size flexibility works only within one family and platform. The team keeps paying for the RIs until the term ends, and the new instances are billed at On-Demand rates. Selling the Standard RIs on the Marketplace or leaving them to expire are the options.