Cloud Cost Optimization
Compute Pricing Models
| Model | Discount vs On-Demand | Best For | Risk |
|---|---|---|---|
| On-Demand | 0% | Unpredictable workloads | None |
| Reserved (1yr, No Upfront) | ~30-35% | Stable baseline load | 1yr commitment |
| Reserved (1yr, All Upfront) | ~40% | Stable baseline with cash available | 1yr commitment + capital |
| Reserved (3yr, All Upfront) | ~60-65% | Long-term stable workloads | 3yr lock-in |
| Savings Plans (AWS) | ~40-66% | Flexible (any instance type/region) | Hourly spend commitment |
| Spot / Preemptible | ~70-90% | Fault-tolerant, batch, CI/CD | Can be reclaimed with 2min notice |
Storage Cost Tiers (S3/GCS)
| Tier | Use Case | Retrieval | Cost (relative) |
|---|---|---|---|
| Standard | Frequently accessed data | Immediate | Highest |
| Infrequent Access (IA) | Monthly access or less | Immediate (retrieval fee) | ~45% less storage |
| One Zone IA | Reproducible, infrequent | Immediate (retrieval fee) | ~55% less storage |
| Glacier Instant | Archives accessed 1-2x/year | Milliseconds | ~68% less storage |
| Glacier Flexible | Rarely accessed archives | Minutes to hours | ~83% less storage |
| Glacier Deep Archive | Long-term legal/compliance | 12-48 hours | ~95% less storage |
Hidden Cost Traps
| Cost Type | Description | Mitigation |
|---|---|---|
| Data Egress | ~$0.09/GB for data leaving cloud to internet | Keep processing in same region; use CDN; evaluate Cloudflare |
| Cross-AZ Traffic | ~$0.01/GB between availability zones | Use same-AZ deployments for high-traffic internal services |
| NAT Gateway | $0.045/GB + hourly; private subnets cost | Use VPC endpoints for S3/DynamoDB; consider public subnets for batch |
| Idle resources | Unused EC2, RDS, load balancers | Schedule auto-shutdown for dev/test; delete unused snapshots |
| Oversized instances | Avg CPU utilization often < 10% | Right-size using CloudWatch metrics; use Compute Optimizer |
| Log storage | CloudWatch Logs expensive at scale | Set log retention; send to S3; use Loki as alternative |
FinOps Practices
# AWS Cost tagging strategy
# Enforce required tags with AWS Config or SCPs
Tags:
Environment: prod|staging|dev
Team: platform|payments|data
CostCenter: eng-platform-001
Project: my-project
# AWS Cost Explorer queries (CLI)
aws ce get-cost-and-usage \
--time-period Start=2024-01-01,End=2024-02-01 \
--granularity MONTHLY \
--metrics BlendedCost \
--group-by Type=DIMENSION,Key=SERVICE
# Set budget alerts
aws budgets create-budget \
--account-id 123456789 \
--budget file://budget.json \
--notifications-with-subscribers file://notifications.json
# Tools for cost visibility:
# - AWS Cost Explorer + Cost Anomaly Detection
# - Infracost (Terraform cost estimates in PR)
# - Kubecost (K8s cost breakdown per namespace/team)
# - CloudHealth / Apptio Cloudability (enterprise)