A Savings Plan is a promise to spend a fixed number of dollars per hour on compute for one or three years, in return for lower rates up to that amount. A Compute Savings Plan applies across instance family, size, Region and OS, plus Fargate 24 and Lambda (up to 66% off, AWS 24 says); an EC2 24 Instance Savings Plan is locked to one family in one Region, such as t4g in us-east-1 (up to 72%). The rates are public: on https://pricing.us-east-1.amazonaws.com 8 , the files /offers/v1.0/aws/AmazonEC2/current/region_index.json and /savingsPlan/v1.0/aws/AWSComputeSavingsPlan/current/region_index.json link to per-Region offers. Change .json to .csv in the us-east-1 links, save the 300 MB files as ec2.csv and sp.csv:
#!/usr/bin/env python3
# Usage: python3 sp_compare.py t4g.small (ec2.csv and sp.csv in the current directory)
import csv, itertools, sys
t, rate = sys.argv[1], {}
def rows(path): # skip the five metadata lines above the CSV header
return csv.DictReader(itertools.islice(open(path, newline=""), 5, None))
for r in rows("ec2.csv"): # Linux, shared tenancy, on-demand
if (r["usageType"], r["operation"], r["TermType"], r["Tenancy"], r["CapacityStatus"]) \
== (f"BoxUsage:{t}", "RunInstances", "OnDemand", "Shared", "Used"):
rate["On-Demand"] = float(r["PricePerUnit"])
for r in rows("sp.csv"): # both Savings Plan kinds, 1 and 3 years
if (r["DiscountedUsageType"], r["DiscountedOperation"], r["PurchaseOption"]) \
== (f"BoxUsage:{t}", "RunInstances", "No Upfront"):
kind = "Compute SP" if r["Product Family"] == "ComputeSavingsPlans" else "EC2 Inst SP"
rate[f"{kind} {r['LeaseContractLength']}yr"] = float(r["DiscountedRate"])
print(f"{t:18}{'$/hour':>8}{'$/month':>9}{'saving':>8}")
for plan, p in sorted(rate.items(), key=lambda kv: -kv[1]):
print(f"{plan:18}{p:8.4f}{p * 730:9.2f}{1 - p / rate['On-Demand']:8.0%}")t4g.small $/hour $/month saving On-Demand 0.0168 12.26 0% Compute SP 1yr 0.0121 8.83 28% EC2 Inst SP 1yr 0.0105 7.67 37% Compute SP 3yr 0.0084 6.13 50% EC2 Inst SP 3yr 0.0073 5.33 57%
A t3.small scores nearly the same. Covering this server means committing $0.0121 an hour to save $3.43 a month, far from the advertised maximums. Commit only to usage you are sure of for the whole term; the Savings Plans Recommendations page in the Billing console sizes it from your history.