Cost Optimization
Overview
The Cost Optimization pillar is about delivering business value at the lowest price point: avoiding unnecessary costs, using the right resources and continuously improving. It is not about being cheap at all costs; it is about getting the most value for every dollar while meeting performance, reliability and security needs.
The cloud changes the cost model from large upfront capital expenses to pay-as-you-go operating expenses. That gives you flexibility, but it also means that waste, such as forgotten test environments or oversized databases, shows up on the bill every month.
This lesson focuses on the design principles and architectural levers for cost: right-sizing, elasticity, storage tiering, managed and serverless services, and data-transfer-aware design. The mechanics of pricing models and billing tools are covered in the Cost Optimization chapter.
Key Concepts
- Design principles: implement cloud financial management, adopt a consumption model, measure overall efficiency, stop spending money on undifferentiated heavy lifting, analyse and attribute expenditure.
- Five focus areas: practice cloud financial management, expenditure and usage awareness, cost-effective resources, manage demand and supply, optimise over time.
- Right-size instances and scale elastically; turn off non-production resources outside working hours.
- Pick the right purchase option: On-Demand, Savings Plans/RIs for baseline, Spot for flexible work.
- Use S3 storage classes and lifecycle rules, Intelligent-Tiering for unknown access patterns, and gp3 instead of gp2.
- Prefer managed and serverless services to avoid undifferentiated heavy lifting (RDS, Fargate, Lambda).
- Watch data transfer: cross-AZ, NAT Gateway processing, cross-Region and internet egress.
- Use tags, budgets and Cost Explorer for accountability and visibility.
Detailed Notes
Five focus areas
- Practice Cloud Financial Management (CFM): a FinOps function, budgets, cost-aware culture, executive reporting.
- Expenditure and usage awareness: governance, monitoring, tagging and cost attribution (Cost Explorer, Budgets, CUR).
- Cost-effective resources: choose the right service, resource type, size and pricing model.
- Manage demand and supply resources: match capacity to demand with auto scaling, queues and throttling.
- Optimise over time: review new services and features regularly.
Levers by service
| Area | Lever |
|---|---|
| Compute | Right-size with Compute Optimizer; Graviton (up to ~20% cheaper and up to ~40% better price-performance); Savings Plans for baseline; Spot for fault-tolerant; Lambda for spiky or low-traffic work |
| Scheduling | AWS Instance Scheduler or Systems Manager to stop dev/test outside business hours (about 65% saving for 12 h x 5 days) |
| Storage | S3 lifecycle and Intelligent-Tiering; gp3 is ~20% cheaper than gp2; delete unattached EBS volumes and old snapshots; EFS-IA / lifecycle |
| Database | Right-size, Aurora Serverless v2 for variable load, reserved instances for steady, read replicas only when needed, stop unused instances |
| Network | Gateway endpoints (free) for S3/DynamoDB, CloudFront, keep traffic in the same AZ, one NAT Gateway per AZ only where HA requires |
| Architecture | Serverless, event-driven, SQS buffering to avoid over-provisioning peaks |
S3 storage classes
| Class | Typical use | Retrieval | Min storage duration |
|---|---|---|---|
| Standard | Frequent access | Instant | None |
| Intelligent-Tiering | Unknown / changing access | Instant (auto tiers; archive tiers optional) | None |
| Standard-IA | Infrequent, multi-AZ | Instant, retrieval fee | 30 days |
| One Zone-IA | Infrequent, re-creatable, one AZ | Instant | 30 days |
| Glacier Instant Retrieval | Archive needing ms access | Milliseconds | 90 days |
| Glacier Flexible Retrieval | Archive | Minutes to 12 hours | 90 days |
| Glacier Deep Archive | Long-term compliance | Up to 12-48 hours | 180 days |
Lifecycle policy example
{
"Rules": [
{
"ID": "tier-logs",
"Status": "Enabled",
"Filter": { "Prefix": "logs/" },
"Transitions": [
{ "Days": 30, "StorageClass": "STANDARD_IA" },
{ "Days": 90, "StorageClass": "GLACIER" }
],
"Expiration": { "Days": 365 }
}
]
}
Common sources of waste
- Idle or oversized EC2/RDS instances, unattached EBS volumes, old snapshots, unused Elastic IPs (a charge applies for all public IPv4 addresses) and idle load balancers.
- NAT Gateway processing for traffic that could use endpoints.
- Cross-AZ and cross-Region chatter.
- Over-retained logs (set CloudWatch Logs retention) and data in the wrong storage class.
- Dev/test environments running 24/7.
Matching supply to demand
- Demand-based: auto scaling on metrics, scheduled scaling for known peaks, target tracking.
- Buffer-based: SQS smooths peaks so you provision for average, not peak.
- Throttle: API Gateway usage plans limit costs from abusive clients.
Cost-aware design decisions
Spiky, unpredictable, low volume -> Lambda / Fargate Spot / Aurora Serverless
Steady 24/7 baseline -> Savings Plan + right-sized instances
Interruptible batch -> Spot with SQS
Rarely read data -> S3 IA / Glacier tiers with lifecycle
Global static content -> S3 + CloudFront (cheaper egress, fewer origin requests)
Real World Example
Scenario — a startup cutting a $90,000 monthly AWS bill by 40% without hurting customers.
The startup's bill had grown 3x in a year. The cloud team creates a FinOps working group and starts with visibility: tags on all resources, Cost Explorer grouped by team and a CUR dashboard. Findings include dev/test environments running 24/7, gp2 volumes everywhere, 400 TB of logs in S3 Standard and a NAT Gateway moving 60 TB per month of S3 traffic.
Actions: Instance Scheduler stops dev/test at night and weekends; EBS volumes move to gp3; log buckets get lifecycle rules (Standard -> IA -> Glacier -> expire); an S3 gateway endpoint removes NAT processing; a Compute Savings Plan covers the right-sized baseline; the batch analytics fleet moves to Spot; and the stateless API moves from EC2 to Fargate with Graviton.
Budgets with forecasted alerts and monthly reviews keep the savings in place.
Architecture Diagram
Every layer has a cost lever: purchase model, tiering, endpoints, scheduling and managed services.
- 1Compute is right-sized, runs on Graviton and is covered by a Savings Plan for its baseline.
- 2Bursty work uses Lambda so you pay only while code runs.
- 3S3 data ages from Standard to Glacier through lifecycle rules, and the gateway endpoint avoids NAT charges.
- 4Cost Explorer, Budgets and scheduling automation keep usage visible and waste low.
Best Practices
- ✓Establish FinOps ownership: tag everything, assign budgets to teams and review spend monthly.
- ✓Right-size first, then commit with Savings Plans/RIs; use Spot for interruptible work.
- ✓Stop or schedule non-production resources and delete orphaned volumes, snapshots and IPs.
- ✓Use S3 lifecycle rules and Intelligent-Tiering; set log retention in CloudWatch Logs.
- ✓Prefer managed and serverless services to reduce operational cost.
- ✓Design to avoid data transfer charges: same-AZ traffic, Gateway endpoints, CloudFront.
- ✓Match supply to demand with auto scaling and SQS buffering rather than provisioning for peak.
- ✓Review new instance types and services (for example Graviton, gp3) regularly.
Common Interview Questions
Exam Tips
SAA-C03 focus
- "Unpredictable access pattern, minimise storage cost" -> S3 Intelligent-Tiering; "known aging pattern" -> lifecycle rule.
- "Steady-state baseline" -> Savings Plans/RIs; "interruptible" -> Spot; "spiky/idle" -> Lambda/Serverless.
- "Cut NAT Gateway cost for S3/DynamoDB traffic" -> Gateway endpoint.
- "Stop non-production instances at night" -> Instance Scheduler / Lambda + EventBridge.
- "Recommend instance downsizing" -> Compute Optimizer; "idle resources" -> Trusted Advisor.
- gp3 is cheaper than gp2 and decouples IOPS from size; Graviton gives better price-performance.
- The pillar's principles: consumption model, CFM, measure efficiency, stop undifferentiated heavy lifting, attribute spend.
- The cheapest answer is not always correct: it must still meet performance, availability and security requirements.
Chapter quiz
Architecture Design Principles · 5 questions
1.A company wants to review its production workload against AWS best practices, record the answers, get a prioritised list of high-risk issues and track improvement over time at no extra cost. Which service should it use?
2.A business requires an RPO of a few minutes and an RTO of under 30 minutes for a critical application, while keeping costs lower than a full active/active deployment. Which DR strategy fits BEST?
3.A DynamoDB-backed application needs the lowest possible read latency for a read-heavy leaderboard with minimal code changes. What should the architect add?
4.Administrators currently SSH to private EC2 instances through a bastion host. The company wants to remove open SSH ports and have every session audited. Which solution meets the requirement with the LEAST operational overhead?
5.A security team must ensure that no account in the AWS Organization can disable AWS CloudTrail, even if an administrator in the account has full IAM permissions. What should they use?
0 of 5 answered
Finished this lesson?
0 of 64 lessons done · 0% of the course

