AWS Cost Optimization Architecture — Overview
Cost optimization is not just about spending less — it’s about achieving maximum business value per dollar spent. AWS provides pricing models, tools, and architectural patterns that can reduce costs 30-70% without sacrificing performance. Cost optimization appears in 3 of 4 SAP-C02 domains (Domains 1.5, 2.6, and 3.5), making it the most cross-cutting topic on the exam.
Cost Explorer recs
Match resource to load
Eliminate idle
Reserved Instances
Spot Instances
On-Demand baseline
EBS gp3 (not gp2)
Lifecycle policies
Delete unused
CloudFront egress
Same-AZ placement
NAT GW consolidation
Budgets + Alerts
Anomaly Detection
CUR + Athena
Compute Purchasing Options
| Option | Savings | Commitment | Best For |
|---|---|---|---|
| On-Demand | Baseline (0%) | None — pay per second | Short-term, unpredictable, testing, spikes above baseline |
| Savings Plans (Compute) | Up to 66% | $/hour for 1 or 3 years | Flexible — applies to EC2, Fargate, Lambda across regions/instance families |
| Savings Plans (EC2 Instance) | Up to 72% | $/hour for specific instance family + region | Known instance family/region but flexible on size/OS/tenancy |
| Reserved Instances | Up to 72% | 1 or 3 years, specific instance type | Specific instance type/region. Can sell on RI Marketplace. Being replaced by SPs. |
| Spot Instances | Up to 90% | None — can be interrupted with 2-min notice | Fault-tolerant: batch, CI/CD, big data, containers, training |
| Dedicated Hosts | Varies (can use SPs/RIs) | On-Demand or Reserved | License compliance (BYOL per-socket/per-core), regulatory |
Savings Plans vs Reserved Instances
- Savings Plans (recommended): More flexible — Compute SP applies across EC2, Fargate, Lambda, any region. Commit to $/hour of usage. Automatically applies to highest-savings usage first.
- Reserved Instances: Locked to specific instance type + region. Can be sold on Marketplace (SPs cannot). Standard RI vs Convertible RI (can change instance family).
- Best practice: Use Compute Savings Plans for flexibility. Use EC2 Instance SPs only when you’re certain about instance family + region.
Spot Instance Patterns
- Diversification: Request multiple instance types/AZs. Spot pools with more capacity = fewer interruptions.
- Mixed instances ASG: Base capacity On-Demand + Spot for scaling. Capacity-optimized allocation strategy.
- Spot Fleet: Request Spot across multiple pools with allocation strategy (lowest-price, diversified, capacity-optimized).
- Interruption handling: 2-minute warning via instance metadata or EventBridge. Checkpoint work, drain connections, deregister from ALB.
- Good for: Batch processing, CI/CD builds, big data (EMR), containerized microservices (ECS/EKS with mixed instances), ML training (checkpointing)
- Not good for: Single-instance workloads, databases, stateful without checkpointing
Right-Sizing
| Tool | What It Does | Actionable Output |
|---|---|---|
| AWS Compute Optimizer | Analyzes CPU/memory/network utilization → recommends optimal instance type | “Downsize m5.2xlarge to m5.large” (saves 75%) |
| Cost Explorer (Right-sizing) | Identifies underutilized EC2 instances | Terminate or resize recommendations |
| Trusted Advisor | Checks for idle resources (ELBs, EBS, RDS, EC2) | Low-utilization or idle resource alerts |
| S3 Storage Lens | Analyzes S3 usage patterns across buckets | Identify incomplete multipart uploads, non-current versions, suboptimal storage class |
Storage Cost Optimization
| Optimization | Savings | Action |
|---|---|---|
| S3 Intelligent-Tiering | Auto-moves to cheapest tier (no retrieval fee) | Enable for objects with unknown access patterns |
| S3 Lifecycle Policies | 30-90% on archive data | Standard → IA (30d) → Glacier Flexible (90d) → Deep Archive (180d) |
| EBS gp3 (not gp2) | 20% cheaper, higher baseline IOPS | Migrate all gp2 volumes to gp3 (same performance, less cost) |
| Delete unattached EBS volumes | 100% (eliminate waste) | Trusted Advisor identifies unattached volumes |
| EFS Infrequent Access | Up to 92% on cold files | Enable lifecycle policy (move after 30d of no access) |
| DynamoDB on-demand vs provisioned | 50%+ for predictable workloads | On-demand for spiky. Provisioned + auto-scaling for steady state. |
Network Cost Optimization
- VPC Endpoints (Gateway): S3 and DynamoDB traffic stays in VPC — avoids NAT Gateway data processing charges ($0.045/GB). Free to use.
- VPC Endpoints (Interface): PrivateLink for other services — avoids NAT charges but costs $0.01/GB + $0.01/hr/AZ. Still cheaper than NAT for high-volume.
- NAT Gateway consolidation: Centralize NAT in shared egress VPC (via TGW) instead of per-VPC NATs. One set of NATs shared across all VPCs.
- CloudFront for egress: CF data transfer out is cheaper than direct EC2/S3 egress in most regions. Serve content via CF even without caching benefit.
- Same-AZ placement: Traffic between instances in same AZ is free. Cross-AZ costs $0.01/GB each way. Place tightly coupled services together.
- Direct Connect: Reduced data transfer out rate vs internet ($0.02/GB vs $0.09/GB for first 10TB).
Architectural Patterns for Cost
- Serverless for variable workloads: Lambda + DynamoDB = $0 when idle. vs EC2 running 24/7 even at 5% utilization.
- Graviton (ARM) migration: 20% cheaper, same or better performance. Works with EC2, RDS, ElastiCache, EKS, Lambda.
- Scheduled scaling: Scale down nights/weekends for non-production. ASG scheduled actions or EventBridge → Lambda.
- SQS-based scaling: Decouple intake from processing. Process at optimal (cheapest) rate rather than matching peak.
- Auto Scaling target tracking: Maintain 70% CPU utilization — prevents over-provisioning while avoiding throttling.
Cost Monitoring & Governance
| Tool | Purpose | Key Feature |
|---|---|---|
| Cost Explorer | Visualize, filter, and forecast costs | Right-sizing recommendations, Savings Plan recommendations, 12-month forecast |
| AWS Budgets | Set spend/usage thresholds with alerts | Alert at 80%/100% of budget. Auto-actions (stop EC2, apply SCP). |
| Cost Anomaly Detection | ML-based unusual spending alerts | Detects unexpected spikes (e.g., someone left GPU instances running) |
| Cost & Usage Report (CUR) | Most detailed billing data (line-item) | Deliver to S3 → query with Athena for custom analysis |
| Cost Allocation Tags | Tag resources for cost attribution | Track cost by team/project/environment. Enforce via SCP or Config rules. |
Exam Tips
| Exam | Key Points |
|---|---|
| SAP-C02 | “Reduce cost for steady baseline” → Savings Plans/RI. “Fault-tolerant batch” → Spot. “Variable unpredictable” → On-Demand or serverless. “Reduce data transfer” → VPC Endpoints, CloudFront, same-AZ. “Storage getting expensive” → Lifecycle policies, Intelligent-Tiering, gp2→gp3. “Identify waste” → Compute Optimizer + Trusted Advisor. “Track cost per team” → Cost Allocation Tags + CUR. |
AWS Certification Exam Practice Questions
Question 1:
A company runs 200 EC2 instances 24/7 for their production web application. The instances are a mix of m5.large and m5.xlarge across 3 regions. They want to reduce compute costs by at least 30% while maintaining flexibility to change instance sizes and regions. Which purchasing option provides this?
- Standard Reserved Instances for m5.large in each region
- Compute Savings Plan with a 1-year commitment
- Spot Instances for all 200 instances
- EC2 Instance Savings Plan for the m5 family in each region
Show Answer
Answer: B — Compute Savings Plan provides up to 66% savings and applies across ANY instance family, size, region, OS, and tenancy. It also covers Fargate and Lambda. This gives maximum flexibility while guaranteeing 30%+ savings. EC2 Instance SP (D) locks to a specific family+region. Standard RIs (A) lock to specific type+region. Spot (C) would cause interruptions for a production web app.
Question 2:
A company’s monthly AWS bill shows $15,000/month for NAT Gateway data processing charges. Their workloads in private subnets frequently access S3 and DynamoDB. How should they reduce this cost?
- Replace NAT Gateway with a NAT instance (cheaper)
- Create S3 and DynamoDB Gateway VPC Endpoints (free) to route that traffic without NAT
- Move all workloads to public subnets to eliminate NAT
- Use AWS PrivateLink for S3 access
Show Answer
Answer: B — Gateway VPC Endpoints for S3 and DynamoDB are free (no hourly charge, no data processing charge). Traffic routes through the endpoint instead of the NAT Gateway, eliminating the $0.045/GB NAT data processing fee. If S3/DynamoDB traffic is the majority (common), this can reduce NAT costs by 70-90%. PrivateLink (Interface endpoints) would work but costs $0.01/GB — Gateway endpoints are free.
Question 3:
A data processing workload runs nightly batch jobs on EC2 instances. Jobs take 2-4 hours, are fault-tolerant (can checkpoint and restart), and the company wants maximum cost savings. The workload uses 50 c5.2xlarge instances. Which strategy saves the MOST?
- Spot Instances with capacity-optimized allocation and checkpointing to S3
- Reserved Instances (3-year, All Upfront) for c5.2xlarge
- On-Demand with Compute Savings Plan
- Graviton instances (c7g.2xlarge) on On-Demand
Show Answer
Answer: A — Spot Instances provide up to 90% savings and the workload is ideal for Spot: fault-tolerant, can checkpoint, runs in batch. Capacity-optimized allocation picks pools with most available capacity (fewer interruptions). Even combining Graviton (20%) + Savings Plans (66%) = ~73% max savings, still less than Spot’s 90%. Reserved Instances waste money for a workload that only runs a few hours nightly.
Question 4:
An S3 bucket stores 100TB of log data. 95% of data is never accessed after 30 days, but must be retained for 7 years for compliance. The current storage class is S3 Standard for all data, costing $2,300/month. What lifecycle policy MOST reduces cost while maintaining compliance?
- Move all data to S3 Glacier Deep Archive immediately after upload
- Standard (0-30d) → S3 Standard-IA (30-90d) → S3 Glacier Flexible Retrieval (90d-1yr) → Deep Archive (1yr+)
- Enable S3 Intelligent-Tiering for all data
- Standard (0-30d) → S3 Glacier Deep Archive (30d+)
Show Answer
Answer: B — This multi-tier lifecycle provides optimal cost at each stage: Standard for active access (first 30 days), Standard-IA for occasional access (30-90 days, 54% cheaper), Glacier Flexible for rare retrieval (90d-1yr, 70% cheaper), and Deep Archive for long-term compliance retention (1yr+, 95% cheaper than Standard). Moving directly to Deep Archive (D) risks needing expensive retrieval in the first year. Intelligent-Tiering (C) won’t archive below Glacier Instant Retrieval without lifecycle rules.
Question 5:
A company uses Amazon RDS MySQL (db.r5.2xlarge) running 24/7 in production. AWS Compute Optimizer shows the database averages 15% CPU utilization with peaks of 40%. The company also has unused gp2 EBS volumes from terminated instances. What TWO actions provide the MOST cost savings?
- Downsize RDS to db.r5.large based on Compute Optimizer recommendation
- Switch from RDS to Aurora Serverless v2
- Delete unused gp2 EBS volumes and migrate attached gp2 to gp3
- Enable RDS Reserved Instance for current db.r5.2xlarge
- Move RDS to a Spot-based EC2 instance running MySQL
Show Answer
Answer: A and C — Right-sizing the RDS instance from r5.2xlarge to r5.large (peak 40% on 2xlarge = ~80% on large, which is acceptable) saves 50% on compute. Deleting unused EBS volumes eliminates 100% waste, and migrating gp2→gp3 saves 20% on remaining storage with equal or better performance. Don’t buy an RI for an oversized instance (D). Spot for a production database (E) is not recommended. Aurora Serverless v2 (B) could work but is a bigger change than right-sizing.
Related Posts
- AWS S3 Storage Classes
- AWS EBS Volume Types
- AWS Auto Scaling with ELB
- Serverless API Architecture
- Container Platform Architecture
References
- Cost Optimization Pillar — Well-Architected Framework
- Savings Plans Recommendations — AWS Blog
- Spot Instance Interruption Best Practices — AWS Blog
- Cost Explorer Right-Sizing — AWS Blog
Frequently Asked Questions
Savings Plans vs Reserved Instances — which should I buy?
Savings Plans (recommended) are more flexible: Compute SP applies across EC2, Fargate, Lambda, any region/family. EC2 Instance SP applies to a family+region but flexible on size/OS. Reserved Instances are locked to a specific type+region but can be sold on the Marketplace. For most organizations, Compute Savings Plans offer the best balance of savings and flexibility.
How do I handle Spot interruptions?
Design for interruption: (1) Use capacity-optimized allocation strategy, (2) Diversify across instance types/AZs, (3) Check the 2-minute warning via instance metadata or EventBridge, (4) Checkpoint state to S3/DynamoDB, (5) Use ASG mixed instances with On-Demand base for minimum capacity. Spot interruption rates are typically <5% with diversified pools.
Where should I start with cost optimization?
Start with free wins: (1) Delete unused resources (Trusted Advisor), (2) Right-size overprovisioned instances (Compute Optimizer), (3) Migrate gp2→gp3 EBS, (4) Add S3 lifecycle policies. Then commit: buy Savings Plans for your baseline. Finally architect: VPC Endpoints, CloudFront for egress, serverless for variable workloads, Graviton migration.