Servisphere

Module 13 · SAA-C03

Cost optimization

How to buy EC2 (On-Demand, Savings Plans, Reserved, Spot), cheap storage classes, data transfer costs and cost monitoring tools.

  • DomainCost-optimized architectures
  • 9 diagrams
  • 11 scenarios
  • 13 services

5-minute essentials

  1. On-Demand: pay per second / hour, no commitment.Suits short-term, unpredictable or experimental workloads. It is the highest price, used as the baseline for comparison.
  2. Savings Plans: commit to spending a fixed USD amount per hour for 1 or 3 years in exchange for lower prices than On-Demand.Compute Savings Plans are the most flexible (any family, Region, OS; plus Fargate and Lambda). EC2 Instance Savings Plans discount more deeply but are tied to one family in one Region.
  3. Reserved Instances: reserve a specific configuration for 1 or 3 years. Standard discounts more deeply and can be resold on the Marketplace; Convertible can be exchanged for another configuration.RDS, ElastiCache, Redshift and OpenSearch still have their own reserved pricing; if the question says a database runs steadily 24/7 → reserved / Database Savings Plans.
  4. Spot Instances: use spare EC2 capacity, up to 90% off, but AWS can reclaim them with only a 2-minute warning.Suits interruption-tolerant work: batch, image processing, CI, EMR task nodes, stateless workers. Not for databases or work that cannot stop.
  5. Combine: buy Savings Plans / RI for the steady base, run the fluctuating part On-Demand, run interruption-tolerant work on Spot.An Auto Scaling group with a mixed instances policy blends On-Demand and Spot, using several instance types to reduce reclaim risk.
  6. Dedicated Host: an entire physical server just for you, with visible sockets / cores.When the question mentions software licensing per socket / core (BYOL) or compliance requirements → Dedicated Host.
  7. Rightsize before committing: Compute Optimizer recommends better-fitting instances, EBS volumes and Lambda settings.Committing to Savings Plans for oversized instances locks in the waste for 1–3 years.
  8. S3: pick the storage class by access frequency and use lifecycle rules to transition / delete automatically.Standard-IA and One Zone-IA bill a 30-day minimum, Glacier Instant / Flexible 90 days, Deep Archive 180 days; IA bills a 128 KB minimum per object.
  9. S3 Intelligent-Tiering when the access pattern is unknown: it moves tiers automatically, with no retrieval fees, only a per-object monitoring fee.Objects smaller than 128 KB are not monitored and always stay in the Frequent tier.
  10. Data transfer: data out to the internet and between AZs / Regions is charged; the first 100 GB per month out to the internet is free (aggregated across all services).To reduce it: CloudFront caches near users, gateway endpoints for S3 / DynamoDB instead of going through NAT, keep "chatty" traffic within the same AZ when reasonable.
  11. NAT Gateway is billed per hour and per GB processed.Heavy traffic from a private subnet to S3 / DynamoDB: use a gateway endpoint (free) instead of going through NAT.
  12. Cost Explorer views and forecasts costs and suggests Savings Plans / RI purchases. Budgets sets thresholds, sends alerts and can run actions automatically."Alert when cost is about to exceed" → Budgets; "analyze trends, find which service costs the most" → Cost Explorer.
  13. Cost and Usage Report (Data Exports) is the most detailed cost data, exported to S3 and queried with Athena.Attach cost allocation tags to split costs by project / department.
  14. AWS Organizations consolidated billing: combines usage across accounts to reach tiered pricing and shares Savings Plans / RI between accounts.When the question mentions many accounts, one bill and shared discounts → Organizations.
  15. Turn off what you do not use: dev environments outside working hours, orphaned EBS volumes / snapshots, Elastic IPs and public IPv4 addresses (all billed hourly).Trusted Advisor and Cost Optimization Hub list idle or underused resources.

Diagrams

Mixing purchase options by load shape

Mixing purchase options by load shapeAuto Scaling group (mixed instances)discount1scale out23Savings PlansUSD / hour commitBase load10 instances, 24/7On-DemandpeakSpotmany instance typesBatch jobsredoable
The always-on base load is covered by Savings Plans; the peak-hour increase runs On-Demand; interruption-tolerant work runs on Spot. One Auto Scaling group can mix On-Demand and Spot.

Step by step

  1. Savings Plans apply automatically to continuous usage: commit to the base, not the peak.
  2. At peak, add On-Demand instances, paid per second, and drop them when the peak ends.
  3. Interruption-tolerant work runs on Spot, spread across instance types / AZs to reduce simultaneous reclaims.

Handling the Spot interruption warning (2 minutes)

Handling the Spot interruption warning (2 minutes)EC2 (Spot)EventBridgeLambdaAuto Scaling1. Spot Instance Interruption Warning2. Rule triggers Lambda3. Deregister from ALB, checkpoint to S34. Replace with another (other Spot type or On-Demand)
AWS emits an event 2 minutes before reclaiming. The application uses that time to deregister from the load balancer and save in-progress work.

S3 lifecycle: transition classes by data age

S3 lifecycle: transition classes by data age30 days190 days2180 days21 year33Standard0–30 daysStandard-IA30-day minimumGlacier Instant90-day minimumGlacier Flexibleminutes – hoursDeep Archive180-day minimumDelete (expire)after 7 years
New, frequently read data sits in Standard; as it ages and is read less, move it to cheaper classes; delete it when the retention period ends. Remember each class's minimum storage duration.

Step by step

  1. After 30 days of little reading: Standard-IA, still readable immediately but with a retrieval fee.
  2. The older it gets, the cheaper the class; Glacier Flexible must be restored before reading.
  3. Long-term storage in Deep Archive, then automatic deletion when retention ends.

Reaching S3 via NAT or a gateway endpoint

Reaching S3 via NAT or a gateway endpointVPCPublicPrivatecostly11cheap22AppNAT Gateway$ / hr + $ / GBGateway endpointfreeS3
Through a NAT Gateway: you pay an hourly fee plus a per-GB processing fee. Gateway endpoint: a destination in the route table, no charge, traffic never leaves the AWS network.

Step by step

  1. Without an endpoint: every GB to S3 incurs NAT processing fees.
  2. Add a gateway endpoint to the private subnet's route table: traffic to S3 goes directly, with no endpoint charge.

CloudFront cuts origin load and cost

CloudFront cuts origin load and costRegion1on miss only2API2Global usersCloudFrontcache hit: instantS3images, videoALBAPI
Content is cached at edges near users; only cache misses go back to the origin. The origin receives fewer requests and users download faster.

Step by step

  1. Users download from the nearest edge.
  2. The origin serves only cache misses and dynamic requests.

AWS Budgets: alerts and automatic actions

AWS Budgets: alerts and automatic actionsalert11over 100%22AWS Budgetsforecast > 80%SNS / emailBudget actionapply IAM policy / SCPManagementDev accountblocked from creating
A budget tracks actual and forecast cost. When a threshold is crossed it sends email / SNS, and can automatically apply an IAM policy or SCP to block creating more resources.

Step by step

  1. Forecast cost exceeds 80% of the budget: send an alert.
  2. Budget exceeded: the budget action applies a policy that blocks creating new resources.

Detailed cost reporting: CUR + Athena

Detailed cost reporting: CUR + Athena1exports2SQL33Cost and Usage Reportwith tag columnsS3ParquetAthenaDashboardProject tagProject=shop
The Cost and Usage Report (Data Exports) writes every cost line item, with cost allocation tags, to S3; Athena queries it with SQL, Quick builds dashboards.

Step by step

  1. Enable cost allocation tags so tags appear in the cost report.
  2. The detailed report is written to S3.
  3. Athena queries cost by project, and a dashboard displays it for finance.

Organizations: one bill, shared discounts

Organizations: one bill, shared discountsAWS Organization111shares SP2Management accountone billProd accountbuys Savings PlansDev accountuses the surplusData accountpooled S3 GB
The management account pays one bill for the whole organization. Usage is combined to reach lower price tiers; Savings Plans / RI are shared between accounts.

Step by step

  1. Costs from all accounts merge into one bill; usage is pooled to reach tiered pricing.
  2. Savings Plans bought in prod but not fully used automatically apply to dev (unless sharing is turned off).

Choosing how to buy EC2

Choosing how to buy EC2Yes1No2Yes2No3Yes2NoYesNo3Can the work be stoppedmidway (batch jobs, parallelprocessing)?Steady and predictable for1–3 years?May change instance family,Region, or move to Fargate /Lambda?Must be certain of capacityin one AZ?Spot: up to 90% cheaper,2-minute warningCompute Savings PlansEC2 Instance SavingsPlans / Standard RIOn-Demand CapacityReservationOn-Demand
You usually mix several options: commit the base load to Savings Plans, run the fluctuating part On-Demand, and run interruption-tolerant work on Spot. A Capacity Reservation only holds capacity and gives no discount: pair it with Savings Plans or Regional RIs to get both capacity and a discount.

Step by step

  1. Video rendering, CI, batch data processing: Spot, mixing several instance types to reduce reclaims.
  2. Always-on base load that may change instance family or move to containers: Compute Savings Plans are the most flexible.
  3. Short-term, unpredictable load: On-Demand, paid per second, no commitment.

Quick comparisons

Ways to buy EC2

On-DemandSavings PlansReserved InstancesSpot
CommitmentNoneUSD / hour, 1 or 3 yearsSpecific configuration, 1 or 3 yearsNone
Discount (max)0%Compute up to 66%, EC2 Instance up to 72%Standard deeper than ConvertibleUp to 90%
FlexibilityHighestCompute: any family / Region / Fargate / LambdaConvertible can be exchanged; Standard can be resoldCan be reclaimed, 2-minute warning
Use whenShort-term, unpredictableSteady base, architecture may changeSteady base, fixed configurationInterruption-tolerant work

S3 storage classes by cost

ClassAccessMinimum storageNotes
StandardFrequent, millisecondsNone≥ 3 AZs
Intelligent-TieringUnknown in advanceNonePer-object monitoring fee, no retrieval fee
Standard-IAInfrequent, still needs milliseconds30 days, 128 KBPer-GB retrieval fee
One Zone-IAInfrequent, re-creatable data30 days, 128 KBOnly 1 AZ
Glacier Instant RetrievalAbout once a quarter, milliseconds90 days, 128 KBRetrieval fee
Glacier Flexible RetrievalAbout once a year, minutes to hours90 daysMust restore before reading
Glacier Deep ArchiveLess than once a year, hours180 daysCheapest; must restore

Cost management tools

ToolWhat it doesCommonly asked
Cost ExplorerView, filter and forecast costs; suggests Savings Plans / RIWhich service is driving cost up? How many Savings Plans should I buy?
BudgetsThresholds on cost / usage / RI and SP coverage; alerts; actionsAlert when about to exceed budget, automatically apply a blocking policy
Cost and Usage Report / Data ExportsLine-item detail exported to S3Analyze with Athena, custom dashboards
Compute OptimizerRightsizing recommendations for EC2, EBS, Lambda, ECSUnderused instances, picking a cheaper instance type
Trusted AdvisorChecks for idle resources and suboptimal configurationFind unattached EBS volumes, spare EIPs, etc.
Pricing CalculatorEstimates cost before buildingQuote a new architecture

Reducing data transfer cost

SituationCheaper way
Private subnet reading / writing a lot of S3 / DynamoDBGateway endpoint instead of NAT Gateway
Global users downloading static contentCloudFront caching at the edge
Two services exchanging a lot of dataPlace them in the same AZ if it does not hurt high-availability requirements
Backing up to another RegionCopy only what is needed, compress, choose a cheap storage class at the destination

Exam scenarios

1An application runs steadily 24/7 on EC2 for the next 3 years, but the team wants to be able to change instance family and move part of it to Fargate.

Show answer

Right: 3-year Compute Savings Plans
Apply to EC2 of any family / Region and also to Fargate and Lambda.

Wrong: Standard Reserved Instances
Tied to a configuration, do not apply to Fargate.

Wrong: EC2 Instance Savings Plans
Tied to one family in one Region, do not include Fargate.

2Thousands of images must be processed every night; the job can be redone if stopped midway; wants the cheapest option.

Show answer

Right: Spot Instances (e.g. AWS Batch or Auto Scaling with Spot, several instance types)
Interruption-tolerant work, up to 90% off.

Wrong: On-Demand
Works but costs much more.

Wrong: Reserved Instances
You pay for the whole day although it runs only a few hours.

3A website has a steady base load of 10 instances and needs up to 30 more for a few hours at peak.

Show answer

Right: Savings Plans / RI for the 10-instance base, On-Demand (and Spot if interruption is tolerable) for the peak via Auto Scaling
Each part of the load uses the purchase option that fits it.

Wrong: Buy Savings Plans for 40 instances
You pay for peak capacity even off-peak.

4Logs must be kept for 7 years by regulation; they are viewed often in the first 30 days, afterwards almost never, and waiting a few hours is acceptable if needed.

Show answer

Right: Lifecycle: Standard for 30 days → Glacier Deep Archive, delete after 7 years
Deep Archive is the cheapest for data that can wait a few hours to restore.

Wrong: Leave it in S3 Standard
Pays a high price for data that is almost never read.

Wrong: One Zone-IA for everything
Compliance data should not sit in a single AZ; still costlier than Glacier.

5A bucket holds millions of objects with unpredictable access patterns.

Show answer

Right: S3 Intelligent-Tiering
Moves tiers automatically by access, no retrieval fees.

Wrong: Write your own transition job based on access logs
High operational effort and error-prone.

6The NAT Gateway bill is very high because EC2 instances in a private subnet download large amounts of data from S3 in the same Region.

Show answer

Right: A gateway endpoint for S3 and add a route to the private subnet's route table
Traffic to S3 bypasses NAT; gateway endpoints are free.

Wrong: Switch to a NAT instance
Still pays for data transfer, plus extra operations work.

7Data transfer out to the internet is expensive because global users download images and video from EC2.

Show answer

Right: Put CloudFront in front, move static content to S3 as the origin
Content is cached at the edge, fewer fetches from the origin; users are also faster.

Wrong: Increase the instance size
Does not reduce the amount of data going out to the internet.

8Management wants an email when the monthly cost is forecast to exceed 80% of the budget, and to automatically block new resource creation once it is exceeded.

Show answer

Right: AWS Budgets with an 80% forecast alert (SNS / email) and a budget action applying an IAM policy or SCP
Budgets supports actual and forecast thresholds, plus automatic actions.

Wrong: Cost Explorer
For viewing and analysis; it does not send threshold alerts.

Wrong: CloudWatch billing alarm
Only alerts on actual incurred cost, with no forecast or actions like Budgets.

9A company has 30 AWS accounts and wants one bill, and Savings Plans bought in one account to be used by the others.

Show answer

Right: AWS Organizations with consolidated billing
One bill, tiered discounts computed on total usage, Savings Plans / RI shared between accounts.

Wrong: Each account buys its own Savings Plans
Easy to have a surplus in one place and a shortage in another.

10Finance needs to split costs by project and build detailed reports with SQL.

Show answer

Right: Attach cost allocation tags per project, export Cost and Usage Report (Data Exports) to S3, query with Athena
CUR is the most detailed data and has tag columns.

Wrong: Read the monthly PDF invoice
Not detailed enough, does not split by project.

11Licensed database software is priced per physical core, and the company wants to use its existing license on EC2.

Show answer

Right: EC2 Dedicated Host
Exposes physical sockets / cores, so per-core BYOL licenses can be used.

Wrong: Dedicated Instances
Dedicated hardware, but sockets / cores are not visible or controllable for licensing.

Quick picks

Where do you optimize cost first?

When you needUse
Continuous base load, may change family / move to FargateCompute Savings Plans · see diagram
Fixed base load on one family in one RegionEC2 Instance Savings Plans or Standard RI · see diagram
Interruption-tolerant workSpot (several instance types, handle the 2-minute warning) · see diagram
Licensing per socket / coreDedicated Host
Data gets read less as it agesS3 lifecycle to IA / Glacier · see diagram
Unknown access patternS3 Intelligent-Tiering
High NAT fees from traffic to S3 / DynamoDBGateway endpoint · see diagram
High data transfer out to the internetCloudFront · see diagram
Alert / block when about to exceed budgetAWS Budgets + budget action · see diagram
Detailed cost reports by tagCost and Usage Report + Athena · see diagram
Many accounts, one bill, shared discountsOrganizations consolidated billing · see diagram
Instances using few resourcesCompute Optimizer (rightsizing) before committing

Common pitfalls

  • Using Spot for databases or work that cannot be stopped midway.
  • Buying Savings Plans / RI for peak load instead of the base load.
  • Committing before rightsizing: locks in waste for 1–3 years.
  • Choosing Standard RI when you know the family will change: Convertible RI or Compute Savings Plans fit better.
  • Transitioning small or short-lived objects to Standard-IA / Glacier: you get billed the 128 KB minimum and 30 / 90 / 180 days.
  • Choosing Glacier Flexible Retrieval / Deep Archive for data that must be read immediately: you must restore and wait minutes to hours.
  • Sending all S3 traffic through a NAT Gateway instead of the free gateway endpoint.
  • Forgetting inter-AZ data transfer fees when designing services that exchange a lot of data.
  • Using Cost Explorer when the question needs threshold alerts: that is Budgets.
  • Forgetting unused EBS volumes, snapshots and Elastic IPs: they still cost money.
  • Thinking Dedicated Instances solve per-core licensing: you need a Dedicated Host.

Services in this module

Numbers that change (checked against AWS docs)

  • Spot Instances are up to 90% cheaper than On-Demand. checked 2026-10-16 ↗
  • The Spot interruption warning is issued 2 minutes before the instance is stopped / terminated (via EventBridge and instance metadata). checked 2026-10-16 ↗
  • There are 4 Savings Plans types: Compute (up to 66%, covers EC2, Fargate, Lambda), EC2 Instance (up to 72%, one family in one Region), Database (up to 35%), SageMaker AI (up to 64%). checked 2026-10-16 ↗
  • Savings Plans have 1- or 3-year terms, paid All upfront / Partial upfront / No upfront. checked 2026-10-16 ↗
  • Standard RIs cannot be exchanged but can be sold on the RI Marketplace; Convertible RIs can be exchanged but not sold on the Marketplace. checked 2026-10-16 ↗
  • AWS Budgets updates its data up to 3 times a day; alerts are based on actual or forecast cost, sent by email / SNS. checked 2026-10-16 ↗
  • S3 Standard-IA and One Zone-IA: 30-day and 128 KB minimums; Glacier Instant / Flexible Retrieval: 90 days; Deep Archive: 180 days. checked 2026-10-16 ↗
  • S3 Intelligent-Tiering has no retrieval fees; objects under 128 KB are not monitored and always stay in the Frequent Access tier. checked 2026-10-16 ↗
  • The first 100 GB of data out to the internet each month is free (aggregated across all services and Regions, excluding China and GovCloud). checked 2026-10-16 ↗
  • A gateway endpoint for S3 has no additional charge. checked 2026-10-16 ↗
  • Every public IPv4 address attached to a resource in a VPC is billed hourly, including Elastic IPs in use. checked 2026-10-16 ↗
  • An On-Demand Capacity Reservation holds EC2 capacity in one AZ, can be used immediately with no commitment, and gives no discount by itself; combine with Savings Plans or Regional RIs to get a discount. checked 2026-10-19 ↗
Practice this module →