Cost-Optimized Compute and Storage
Design cost-optimized compute and storage: EC2 purchase options (On-Demand, Savings Plans, Reserved Instances, Spot), right-sizing and Graviton, serverless economics, S3 storage classes and lifecycle policies, and cheaper EBS choices.
Cost Is a Design Requirement
Cost isn’t something you fix after launch. It’s a requirement like availability. The cost-optimized answer on the exam is the cheapest design that still meets every stated requirement, not the cheapest design overall.
The big levers, in rough order of impact:
- Don’t run what you don’t need (turn off dev environments at night, delete idle resources)
- Right-size what you do run
- Pay less per unit with commitments or Spot
- Use the right storage tier for how often data is accessed
- Reduce data transfer (covered in the next lesson)
EC2 Purchase Options
| Option | Discount vs On-Demand | Commitment | Best for |
|---|---|---|---|
| On-Demand | None | None | Short-term, unpredictable, or new workloads |
| Compute Savings Plans | Up to 66% | $/hour for 1 or 3 years | Steady usage that may change instance family, Region, or move to Fargate or Lambda |
| EC2 Instance Savings Plans | Up to 72% | $/hour for 1 or 3 years in one instance family and Region | Steady usage on a known family |
| Reserved Instances | Up to 72% | A specific instance configuration for 1 or 3 years | Steady usage; also available for RDS, ElastiCache, Redshift, OpenSearch |
| Spot Instances | Up to 90% | None, but AWS can reclaim them with a 2-minute warning | Fault-tolerant, flexible work: batch, CI, rendering, stateless web tiers |
| Dedicated Hosts | — | Optional | Licensing tied to physical cores or sockets, compliance |
Discount figures are AWS’s “up to” numbers. Actual savings depend on term, payment option, and instance.
Most real workloads layer these options:
Right-sizing and Graviton
- AWS Compute Optimizer analyzes utilization and recommends smaller or different instance types, EBS volumes, and Lambda memory settings.
- Graviton (Arm) instances usually cost less than comparable x86 instances and often perform better, if your software runs on Arm.
- Auto Scaling removes capacity when it isn’t needed. A fleet sized for peak all day wastes money all night.
Serverless economics
Lambda and Fargate charge for what runs, so idle costs nothing (Lambda) or very little. For spiky or low-volume workloads, serverless is often far cheaper than an always-on instance. For very high, steady load, well-utilized instances with Savings Plans can win. Compute Savings Plans cover Lambda and Fargate too.
Common mistake: a design runs a single-instance production database or a long, non-checkpointed job on Spot “to save 90%.”
Spot capacity can be reclaimed with a 2-minute notice. Use it only for work that is stateless, checkpointed, or spread across many instances that can absorb the loss of a few, and diversify across instance types and AZs.
S3 Storage Classes
| Class | Access pattern | Retrieval | Minimum storage duration |
|---|---|---|---|
| S3 Standard | Frequent | Milliseconds | None |
| S3 Intelligent-Tiering | Unknown or changing | Milliseconds (optional archive tiers are slower) | None; small monitoring fee per object |
| S3 Standard-IA | Infrequent, but needs fast access | Milliseconds, per-GB retrieval fee | 30 days |
| S3 One Zone-IA | Infrequent, re-creatable data | Milliseconds; stored in one AZ | 30 days |
| S3 Glacier Instant Retrieval | Rare (about once a quarter), needs instant access | Milliseconds | 90 days |
| S3 Glacier Flexible Retrieval | Archive | Minutes to hours | 90 days |
| S3 Glacier Deep Archive | Long-term archive, rarely if ever read | Within 12 hours (standard) or 48 hours (bulk) | 180 days |
The classes trade storage price against access price:
Lifecycle policies move objects between classes and delete them automatically:
- 0 Standard
Days 0–30: active use
- 30 Standard-IA
Day 30: occasional reads
- 90 Glacier Flexible
Day 90: archive
- 1y Deep Archive
Year 1: compliance hold
- 7y Expire
Year 7: delete
Also add lifecycle rules that delete old object versions in versioned buckets and abort incomplete multipart uploads. Both quietly add up.
EBS and file storage savings
- Move gp2 to gp3: usually about 20% cheaper per GB, with performance you can tune separately.
- Use st1 or sc1 for large sequential data that doesn’t need SSD.
- Delete unattached volumes and old snapshots; archive rarely needed snapshots with EBS Snapshots Archive.
- Turn on EFS lifecycle management to move cold files to the Infrequent Access or Archive class.
Key Takeaway
Layer Savings Plans or RIs under the steady baseline, On-Demand for the predictable rise, and Spot for interruptible work. Right-size with Compute Optimizer, consider Graviton, and use serverless for spiky load. Match S3 storage classes to access patterns, automate moves with lifecycle policies, and move EBS to gp3.
Use the AWS Pricing Calculator to estimate a month of compute for an API that handles about 2 million requests a day, mostly during business hours:
- Two
m7i.largeOn-Demand instances running 24/7 behind an ALB - The same, but with a 1-year Compute Savings Plan for the baseline
- Lambda + API Gateway, assuming 200 ms average duration at 512 MB
Compare the totals, then write one sentence on when each design would be the right choice. (Hint: think about steadiness of traffic and operational effort, not just price.)
1. A nightly batch job can be stopped and resumed from checkpoints at any time. Which purchase option is MOST cost-effective?
Spot gives the deepest discount and suits interruptible, checkpointed work.
2. A company runs steady compute 24/7 but expects to change instance families and move some services to Fargate. Which option fits BEST?
Compute Savings Plans apply across instance families, Regions, and to Fargate and Lambda.
3. Log files are read often for 30 days, rarely for a year, and must be kept for 7 years for compliance. What is the MOST cost-effective approach?
Lifecycle policies move data to cheaper classes as access drops, ending in Deep Archive for long-term retention.
4. Access patterns for a data set are unknown and change often. Which S3 class lowers cost without you predicting access?
Intelligent-Tiering moves objects between access tiers automatically based on observed access, with no retrieval fees.