Reading20 min read·Module 4

Data Transfer Cost Optimization

Key concepts

  • Data transfer pricing

  • Same-region vs cross-region

  • VPC endpoints savings

  • CloudFront for egress

  • PrivateLink costs

Overview

AWS data transfer costs can account for up to 20% of your cloud bill and are often overlooked. Understanding data transfer pricing and implementing optimization strategies is critical for cost-effective architectures and the SAA-C03 exam.

Core Concept

Data transfer costs follow a pattern: Inbound is free, outbound costs money, and private is cheaper than public. Same-AZ private transfers are free, cross-AZ costs $0.01/GB each way, and internet egress costs $0.09+/GB. VPC endpoints and CloudFront can dramatically reduce these costs.

Exam Tip

Exam questions often present scenarios with high data transfer costs. Look for opportunities to use VPC Gateway Endpoints (free for S3/DynamoDB), CloudFront for content delivery (free origin fetch), and same-AZ placement to eliminate cross-AZ charges.

Key Concepts

Data Transfer Pricing Overview

AWS Data Transfer Pricing Zones
Figure 1: AWS Data Transfer Pricing by Location

Same-AZ Data Transfer

Using Private IP (IPv4 or IPv6)

  • Within same VPC: FREE
  • Within same AZ and VPC: FREE

Using Public/Elastic IP

  • Same AZ: $0.01/GB in + $0.01/GB out
  • Avoid public IPs for internal traffic!

Best Practice:

  • Always use private IPs for internal communication
  • Place tightly-coupled services in the same AZ

Cross-AZ Data Transfer

Within Same Region

  • Standard: $0.01/GB in each direction ($0.02 total)
  • VPC Peering (cross-AZ): $0.01/GB each direction
  • VPC Peering (same-AZ): FREE

Impact Example:

  • 100 TB cross-AZ per month = $2,000 in transfer costs
  • Same workload in single AZ = $0

Considerations:

  • Multi-AZ provides high availability
  • Balance HA requirements against data transfer costs
  • Minimize unnecessary cross-AZ communication

Cross-Region Data Transfer

Typical Pricing

  • US East to US West: $0.02/GB
  • US to Europe/Asia: $0.02/GB
  • Region to same region (adjacent): $0.01-0.02/GB

S3 Cross-Region Replication

  • Replication transfer: $0.02/GB (varies by region)
  • Plus storage costs in destination region

Cost-Saving Strategies:

  • Minimize cross-region data movement
  • Use regional services when possible
  • Consider data residency requirements vs. cost

Internet Egress

Tiered Pricing (per month) | Volume | Cost/GB | |--------|---------| | First 100 GB | FREE | | Up to 10 TB | $0.09 | | Next 40 TB | $0.085 | | Next 100 TB | $0.07 | | Over 150 TB | $0.05 |

Key Points:

  • Ingress (data IN) is always FREE
  • Egress (data OUT) to internet is charged
  • Regional egress pricing varies
  • CloudFront can reduce egress costs

VPC Endpoints Cost Savings

VPC Endpoint Data Transfer Savings
Figure 2: VPC Endpoint Cost Savings Architecture

Gateway Endpoints (S3 & DynamoDB)

Pricing

  • No hourly charge
  • No data processing charge
  • Completely FREE to use

How It Works:

  • Route table entry directs traffic to endpoint
  • Traffic stays on AWS private network
  • No NAT Gateway required for S3/DynamoDB access

Cost Savings Example: Without Gateway Endpoint (via NAT Gateway):

  • 10 TB to S3 = $450 NAT processing
  • Plus NAT hourly: ~$32/month

With Gateway Endpoint:

  • 10 TB to S3 = $0

Always Enable: No reason not to use for S3/DynamoDB access

Interface Endpoints (PrivateLink)

Pricing

  • Hourly charge: ~$0.01/hour per AZ (~$7.30/month)
  • Data processing: ~$0.01/GB

When to Use:

  • Access AWS services privately (not S3/DynamoDB)
  • Connect to third-party SaaS services
  • Avoid NAT Gateway for specific service access

Cost Comparison (1 TB/month to a service): | Method | Monthly Cost | |--------|--------------| | NAT Gateway | $45 processing + $32 hourly = $77 | | Interface Endpoint | $10 processing + $7 hourly = $17 | | Savings | $60/month (78%) |

Multi-AZ Note:

  • As of April 2022, inter-AZ data transfer for PrivateLink is FREE
  • Still charged hourly per AZ endpoint

CloudFront for Data Transfer Optimization

CloudFront Origin Fetch Savings
Figure 3: CloudFront S3 Origin Fetch Architecture

CloudFront with S3 Origins

Data Transfer to CloudFront

  • S3 to CloudFront: FREE
  • ALB to CloudFront: FREE
  • API Gateway to CloudFront: FREE

CloudFront to Users

  • Cheaper than direct S3 egress
  • Regional edge caching reduces origin fetches
  • Price classes control geographic distribution

Cost Comparison (10 TB/month delivered): | Method | Cost | |--------|------| | Direct S3 internet egress | $870 | | CloudFront delivery | ~$850 | | Plus: Caching reduces origin load | Additional savings |

Additional Benefits:

  • Performance improvement (edge caching)
  • DDoS protection (Shield Standard included)
  • Custom domain support

CloudFront Price Classes

Available Price Classes | Class | Edge Locations | Use Case | |-------|---------------|----------| | All | Global | Maximum performance | | 200 | Excludes expensive regions | Cost/performance balance | | 100 | US, Canada, Europe only | Lowest cost |

Savings Commitment

  • 1 or 3-year commitment
  • Up to 30% discount on CloudFront usage
  • Committed minimum monthly usage

Compression Benefits:

  • Enable automatic compression
  • Reduces bytes transferred
  • Lower costs + faster delivery

NAT Gateway Optimization

NAT Gateway vs Alternatives

ScenarioNAT Gateway CostAlternativeAlternative Cost
S3 access from private subnet$0.045/GB + hourlyS3 Gateway EndpointFREE
DynamoDB access$0.045/GB + hourlyDynamoDB Gateway EndpointFREE
SQS/SNS/other AWS service$0.045/GB + hourlyInterface Endpoint$0.01/GB + hourly
Internet access required$0.045/GB + hourlyNAT Gateway (unavoidable)Same
Multiple AZs, heavy trafficNAT per AZShared NAT (less HA)Reduced but risky
SHCreate S3 Gateway Endpoint
# Create VPC Gateway Endpoint for S3 (FREE)
aws ec2 create-vpc-endpoint \
  --vpc-id vpc-12345678 \
  --service-name com.amazonaws.us-east-1.s3 \
  --route-table-ids rtb-12345678

# Create VPC Gateway Endpoint for DynamoDB (FREE)
aws ec2 create-vpc-endpoint \
  --vpc-id vpc-12345678 \
  --service-name com.amazonaws.us-east-1.dynamodb \
  --route-table-ids rtb-12345678

# Create Interface Endpoint for other services
aws ec2 create-vpc-endpoint \
  --vpc-id vpc-12345678 \
  --vpc-endpoint-type Interface \
  --service-name com.amazonaws.us-east-1.sqs \
  --subnet-ids subnet-12345678 subnet-87654321

Data Transfer Pricing Summary

AWS Data Transfer Pricing Reference

Transfer TypeCostNotes
Same AZ, Private IPFREEAlways use private IPs internally
Same AZ, Public IP$0.02/GB totalAvoid for internal traffic
Cross-AZ, Same Region$0.02/GB total$0.01 each direction
Cross-Region$0.01-0.02/GBVaries by region pair
VPC Peering, Same AZFREEGreat for cross-account, same AZ
VPC Peering, Cross-AZ$0.02/GB totalSame as regular cross-AZ
Internet IngressFREEAll inbound is free
Internet Egress$0.09/GBAfter 100 GB free tier
S3/DynamoDB Gateway EndpointFREENo hourly, no data charge
Interface Endpoint$0.01/GB + $0.01/hrPer AZ, inter-AZ now free
NAT Gateway Processing$0.045/GBPlus hourly charges
CloudFront Origin FetchFREES3, ALB, API Gateway origins

Best Practices

  1. Always Use Gateway Endpoints: S3 and DynamoDB Gateway Endpoints are free—always enable them
  2. Evaluate Interface Endpoints: For heavy AWS service usage, compare to NAT Gateway costs
  3. Use CloudFront for Content Delivery: Free origin fetch, cheaper egress than direct S3
  4. Minimize Cross-AZ Traffic: Place tightly-coupled services in the same AZ
  5. Use Private IPs: Never use public IPs for internal communication
  6. Consider CloudFront Price Classes: Use Price Class 100/200 if global coverage isn't needed
  7. Monitor Data Transfer Costs: Use Cost Explorer to identify high-transfer patterns

Common Exam Scenarios

Exam Scenario Decision Guide

ScenarioRecommended SolutionKey Reasoning
EC2 in private subnet accessing S3, high data volumeS3 Gateway EndpointFree, eliminates NAT Gateway processing costs
Application calling AWS APIs (SQS, SNS, etc.) frequentlyInterface Endpoints for each serviceCheaper than NAT Gateway per-GB processing
Static website with global audienceCloudFront with S3 originFree origin fetch, cheaper global delivery, caching
Cross-region disaster recovery with large data syncS3 Cross-Region ReplicationBuilt-in solution, but budget for transfer costs
Microservices communicating heavilySame-AZ deployment when possibleEliminate cross-AZ charges
High NAT Gateway costs identifiedReview for Gateway/Interface Endpoint opportunitiesReplace NAT with endpoints where possible
Multi-region application with shared dataRegional replicas vs cross-region accessReplication cost vs repeated access cost
Private connectivity to third-party SaaSPrivateLink / Interface EndpointSecure, no internet egress

Common Pitfalls

NAT Gateway Data Processing Charges

NAT Gateway charges $0.045/GB for all data processed—in ADDITION to hourly charges. Accessing S3 or DynamoDB through NAT Gateway when Gateway Endpoints (free) exist is a common and expensive mistake.

Public IP Internal Communication

Using public or Elastic IPs for communication between resources in the same VPC incurs $0.01/GB in each direction. Always use private IPs for internal traffic—it's free within the same AZ.

Unnecessary Cross-AZ Traffic

Cross-AZ traffic costs $0.01/GB each direction. Placing frequently-communicating services in different AZs without HA requirements wastes money. Balance availability needs against costs.

Interface Endpoint Per-AZ Charges

Interface Endpoints charge hourly PER Availability Zone. Creating endpoints in 3 AZs = 3x the hourly cost. Only deploy in AZs where the service is actually needed.

Forgetting CloudFront Price Classes

CloudFront's default Price Class "All" includes expensive regions. For US/Europe-focused applications, Price Class 100 or 200 can significantly reduce costs without impacting primary users.

Quick Reference

Data Transfer Cost Quick Guide

FromToCost
InternetAWSFREE
AWSInternet$0.09/GB (after 100 GB free)
Same AZ (private IP)Same AZFREE
Cross-AZCross-AZ$0.02/GB total
S3/DynamoDB via Gateway EndpointEC2FREE
AWS Service via Interface EndpointEC2$0.01/GB
S3/ALBCloudFrontFREE

Key CLI Commands

# List VPC Endpoints
aws ec2 describe-vpc-endpoints --query 'VpcEndpoints[*].[VpcEndpointId,ServiceName,VpcEndpointType]'

# Create S3 Gateway Endpoint
aws ec2 create-vpc-endpoint \
  --vpc-id VPC_ID \
  --service-name com.amazonaws.REGION.s3 \
  --route-table-ids RTB_ID

# Check NAT Gateway data processed (CloudWatch)
aws cloudwatch get-metric-statistics \
  --namespace AWS/NATGateway \
  --metric-name BytesOutToDestination \
  --dimensions Name=NatGatewayId,Value=NAT_GW_ID \
  --start-time 2024-01-01T00:00:00Z \
  --end-time 2024-01-31T23:59:59Z \
  --period 2592000 \
  --statistics Sum

Cost Estimation Formula

Monthly NAT Gateway Cost =
  (Hours × $0.045) + (GB processed × $0.045)

Monthly Interface Endpoint Cost =
  (Endpoints × AZs × Hours × $0.01) + (GB processed × $0.01)

Potential Savings with Gateway Endpoints =
  NAT Gateway Cost for S3/DynamoDB traffic → $0

Test Your Knowledge

Q

A company's AWS bill shows $5,000/month in NAT Gateway data processing charges. Analysis shows 80% of the traffic is to Amazon S3. What is the MOST cost-effective solution?

AUse S3 Transfer Acceleration to speed up transfers
BCreate an S3 Gateway Endpoint in the VPC
CMove the S3 bucket to the same AZ as the EC2 instances
DReplace NAT Gateway with a NAT instance
Q

An application has web servers in us-east-1a and us-east-1b that communicate frequently with a shared Redis ElastiCache cluster. The architect notices high cross-AZ data transfer charges. What should they consider?

AMove all web servers to a single AZ (us-east-1a)
BCreate an ElastiCache cluster in each AZ
CUse CloudFront to cache Redis responses
DEnable VPC Flow Logs to reduce traffic
Q

A media company serves video content directly from S3 to users worldwide. Their data transfer costs are $50,000/month. Which solution would provide the GREATEST cost reduction?

AEnable S3 Transfer Acceleration
BImplement CloudFront with S3 as origin
CMove to S3 Glacier for infrequently accessed videos
DUse S3 Intelligent-Tiering
Q

A SaaS application in a private subnet needs to call AWS SQS and SNS APIs frequently (processing 5 TB/month). Currently using NAT Gateway. What is the MOST cost-effective alternative?

ANo change - NAT Gateway is required for AWS API access
BCreate Interface Endpoints for SQS and SNS
CUse S3 Gateway Endpoint (covers all AWS services)
DMove the application to a public subnet

Further Reading

Related services

S3VPCCloudFront