Cost and Performance Optimization
Buying and measuring
On-Demand suits spiky or short-lived workloads; Savings Plans cover steady compute (Compute SP is flexible across EC2, Fargate, and Lambda; EC2 Instance SP is tied to family and region); Reserved Instances suit predictable workloads, with Convertible RIs allowing family or OS changes; Spot suits fault-tolerant batch with a two-minute interruption notice and no capacity guarantee. Cost Explorer analyzes spend, Budgets alerts and can trigger actions, and the Cost and Usage Report feeds data lakes. Cost allocation tags must be activated before they appear in reports. Compute Optimizer and Trusted Advisor drive rightsizing.
Storage economics
S3 classes are Standard, Intelligent-Tiering (no retrieval fee, small monitoring charge), Standard-IA (30-day minimum), One Zone-IA, Glacier Instant Retrieval, Glacier Flexible, and Deep Archive. Lifecycle rules must respect transition minimums (for example 30 days before Standard-IA) and minimum storage durations. For EBS, gp3 gives a 3,000 IOPS and 125 MiB/s baseline independent of size; gp2 scales at 3 IOPS/GB with burst credits; io2 covers sustained high IOPS; st1 and sc1 are throughput-oriented HDD.
Hidden transfer costs
Inbound data is free; cross-AZ traffic is billed in both directions; cross-region and internet egress are billed; NAT Gateway charges hourly plus per GB processed. Unattached Elastic IPs, idle load balancers, and verbose CloudWatch Logs are common waste.
Traps
Questions compare gp2 and gp3 for a small volume needing 3,000 IOPS - gp3 wins without over-provisioning capacity. Snapshots are incremental, so deleting a later snapshot never breaks earlier ones.
Rule of thumb
Sustained high IOPS on a small volume: gp3 with provisioned IOPS. Large sequential throughput: st1. Archive with minutes-to-hours retrieval: Glacier Flexible. Twelve-hour compliance retrieval: Deep Archive.