Egress Costs: Inter-region Pricing, Optimization Strategies
Network egress cost là "silent killer" của cloud bills. Vì không visible (transparent ở layer-3 networking), team không nhận thức chi phí cho tới khi bill tới.
Một cách hiểu sai: "Egress bé tí, không quan trọng". Thực tế: multi-region data synchronization một lần có thể tốn hàng triệu VND.
Egress Pricing Structure
Internet Egress (Internet-bound traffic)
Tier 1: 0–1 TB/month $0.12/GB
Tier 2: 1–10 TB/month $0.08/GB
Tier 3: 10+ TB/month $0.06/GBExample:
100 GB/month internet egress:
Cost = 100 × $0.12 = $12
10 TB (10,000 GB)/month internet egress:
Tier 1: 1,000 × $0.12 = $120
Tier 2: 9,000 × $0.08 = $720
Total = $840Inter-Region Egress (Between GCP regions)
Inter-region egress not on same continent: $0.02/GB
Examples:
us-central1 → us-east1: $0.02/GB (same continent)
us-central1 → europe-west1: $0.02/GB (same continent)
us-central1 → asia-south1: $0.02/GB (same continent, but premium)
Actually, all inter-region egress: $0.02/GBSame-Region / Same-Zone Traffic
Same region, different zones: FREE
Same zone (technically): FREEThis is key for cost optimization!
Cost Impact: Real Examples
Example 1: Daily Data Sync (TBs)
Scenario: Sync 100 GB database daily from us-central1 to asia-south1
Daily cost: 100 GB × $0.02 = $2
Monthly cost: $2 × 30 = $60
Annual cost: $60 × 12 = $720
With larger dataset (10 TB daily):
Monthly: 10,000 GB × $0.02 × 30 = $6,000/month = $72,000/yearExample 2: CDN Content Delivery
Scenario: Serve 1 TB/day content from us-central1 to asia-southeast1 users
Without CDN (internet egress):
1 TB/day × 30 days = 30 TB/month
30 TB × $0.06 = $1,800/month
With Cloud CDN (origin → cache):
Only cache misses egress from origin
Assume 10% miss rate = 3 TB egress
3 TB × $0.06 = $180/month
Savings: $1,620/month (90%)Optimization Strategies
Strategy 1: Colocation (Same Region)
Principle: Data and compute in same region = no inter-region egress.
Bad architecture:
Database (us-central1) → Application (asia-south1)
→ Inter-region egress for every query
Good architecture:
Database (asia-south1) → Application (asia-south1)
→ Same-region, no egress costImplementation:
- Multi-region data: replicate database to each region
- Application: run in same region as primary data
- Trade-off: Multi-region replication cost vs egress savings
Strategy 2: Cloud CDN (Cache Origin)
CDN mechanics:
- Edge cache near end-user
- Cache hit: data from edge, no origin egress
- Cache miss: data from origin, 1x egress cost
Deployment:
gcloud compute backend-services update my-backend \
--enable-cdn \
--cache-mode=CACHE_ALL_STATICSavings potential: 70–90% egress reduction (assuming high hit rate).
Strategy 3: Cloud Interconnect
For bulk, continuous data flow, Cloud Interconnect cheaper than public internet:
Dedicated Interconnect:
Setup: $0.30/hour per port (10 Gbps)
Usage: No per-GB egress charge
Breakeven:
$0.30/hour × 730 hours = $219/month minimum
If sending > 300 TB/month (breakeven at $0.02/GB × 300 TB = $6k/month):
Cost via Interconnect: $219/month (fixed)
Cost via internet: $6k+/month
Savings: ~$6k/monthStrategy 4: Compression
Every GB compressed = less egress cost.
Scenario: Replicate 500 GB database nightly
Uncompressed:
500 GB × $0.02 = $10/sync
Compressed (2x compression):
250 GB × $0.02 = $5/sync
Compression overhead: 30 seconds CPU
vs Savings: $5/sync × 30 syncs/month = $150/month
ROI: Positive (save money + reduce time)Strategy 5: Data Locality via BigQuery
Bad:
Store data in us-central1
Query from asia-south1
→ Data transfer cost + inter-region egress
Good:
BigQuery regional dataset (asia-south1)
Query locally
→ No data transfer, local query, no egressEgress Cost Visibility
Query Cloud Billing for Egress
SELECT
service.description,
sku.description,
SUM(cost) as egress_cost,
SUM(usage.amount) as usage_gb
FROM `project.billing_dataset.gcp_billing_export_v1`
WHERE sku.description LIKE '%Egress%'
AND DATE(usage_start_time) >= DATE_SUB(CURRENT_DATE(), INTERVAL 30 DAY)
GROUP BY service.description, sku.description
ORDER BY egress_cost DESC;VPC Flow Logs for Traffic Analysis
# Enable VPC Flow Logs
gcloud compute networks update default \
--enable-flow-logs
# Analyze traffic patterns
gcloud logging read \
"resource.type=gce_instance AND
jsonPayload.dest_country='IN'" \
--limit 100Regional Cost Matrix
From / To | us-central1 | europe-west1 | asia-south1
us-central1 | FREE | $0.02 | $0.02
europe-west1 | $0.02 | FREE | $0.02
asia-south1 | $0.02 | $0.02 | FREEInsight: All inter-region egress uniform ($0.02/GB), so regional choice driven by:
- Data residency requirements
- Latency (GCP backbone helps)
- User location
Anti-Patterns
Anti-Pattern 1: Uncontrolled Multi-Region Replication
Scenario: Replicate entire database to 5 regions daily.
Impact:
Database size: 5 TB
Replication: 4 × 5 TB = 20 TB egress/day
Cost: 20 × $0.02 × 30 = $12,000/month
But use case: Dev/test replication (not needed)Fix: Selective replication (only critical data, hot regions).
Anti-Pattern 2: No CDN for Public Content
Scenario: Serve static content (images, JS) from origin every time.
Impact:
10 Gbps continuous traffic = ~38 TB/day
Cost: 38 × $0.06 = $2,280/month
With CDN (80% hit rate):
Cost: (38 × 0.2) × $0.06 = $456/monthFix: Enable Cloud CDN for public content.
Anti-Pattern 3: Ignoring Backup Egress
Scenario: Daily backup to different region, 100 GB/day, but not tracked.
Impact:
Cost: 100 × $0.02 × 30 = $60/month (seems small, but ...)
Annual: $720 + RPO cost + restoration time cost
If using lifecycle policy + local snapshot:
Cost: $0 (same region, free) + storage costFix: Use local snapshots, lifecycle policies for warm storage.
Practical Optimization Checklist
☐ Query egress cost in billing (identify top traffic flows)
☐ Enable Cloud CDN for public content
☐ Collocate databases with applications (same region)
☐ Compress large data transfers (2x reduction typical)
☐ Use Interconnect if sustained > 300 TB/month inter-region
☐ Monitor VPC Flow Logs for unexpected egress patterns
☐ Document data flow in architecture (track egress)
☐ Alert on egress cost spikes (Pub/Sub anomaly detection)
Expected savings: 30–60% egress cost reduction