6.1.6. Network Cost Optimization
š” First Principle: Data transfer in AWS is asymmetric ā most transfers into AWS are free; transfers out to the internet and between regions cost money. Understanding the cost model is an operational skill: architectural decisions about where to place resources affect both performance and the monthly bill.
Data Transfer Cost Model:
| Transfer Type | Cost |
|---|---|
| Inbound from internet to AWS | ā Free |
| Outbound to internet | ~$0.09/GB (varies by region) |
| Between AZs in same region | ~$0.01/GB each way |
| Between regions | ~$0.02ā$0.09/GB (varies) |
| Through VPC endpoint (gateway) | ā Free |
| Through VPC endpoint (interface) | ~$0.01/GB processed |
| NAT Gateway data processing | ~$0.045/GB |
Cost Optimization Strategies:
| Strategy | Savings |
|---|---|
| Use S3/DynamoDB gateway endpoints | Eliminates NAT gateway data processing fees for S3/DynamoDB traffic |
| Keep traffic in-AZ | Place EC2 and RDS in same AZ for inter-component traffic (at cost of HA) |
| Use CloudFront | Cache content at edge ā reduce origin data transfer costs |
| Compress data before transfer | Reduces bytes transferred |
| Use VPC endpoints for AWS services | Avoid NAT gateway processing fees |
A common exam scenario: an EC2 instance in a private subnet transfers 10TB to S3 every day through a NAT gateway. The NAT gateway data processing fee (10TB Ć $0.045/GB = $461/day) is eliminated by adding an S3 gateway endpoint ā routing S3 traffic directly without the NAT gateway.
ā ļø Exam Trap: Inter-AZ data transfer is not free ā it's approximately $0.01/GB each direction. Architectures that communicate heavily between AZs (e.g., a web tier in AZ-a calling a database in AZ-b on every request) incur real costs. The exam may present this as a cost optimization opportunity: move the RDS read replica to the same AZ as the application tier, accepting reduced HA in exchange for cost savings (or use a Multi-AZ setup and direct reads to the local replica).
Reflection Question: A company's monthly AWS bill shows unexpectedly high data transfer costs. Investigation reveals that 50TB/month of traffic flows from EC2 instances in private subnets to S3, all routed through NAT gateways. What is the cheapest architectural change, and roughly how much does it save assuming $0.045/GB NAT processing + $0.09/GB NAT outbound vs. free gateway endpoint traffic?