Menu

Earn Premium with Referrals

Invite your friends and earn Premium rewards through our referral program.

See how it works and start inviting friends.

Egress Estimation
HLD

Egress Estimation

Counting the bytes that leave — user-facing traffic, cross-zone chatter, and why egress dominates cloud bills.

What Egress Means and Why It Bills

Egress = bytes leaving a boundary you pay at. Three boundaries matter:

 1. REGION → INTERNET     ~$0.05–0.12/GB (illustrative market range)
    every byte delivered to users from origin region
 
 2. AZ → AZ (same region) ~$0.01–0.02/GB
    replica reads, chatty service hops pay silently
 
 3. REGION → REGION       ~$0.02–0.09/GB
    cross-region replication, global fan-out

 ingress is free almost everywhere — the asymmetry shapes architecture:
 pull data in freely; push it out thoughtfully

The Core Multiplication

 monthly egress = avg payload × requests/sec × seconds/month

 RideShare rider reads (illustrative):
   2 KB responses × 1,400 rps × 2.6M s ≈ 7 TB/month → hundreds of dollars ✓ fine

 media platform:
   3 MB average video segment × 50k streams/s sustained... 
   ≈ 12 PB/month → millions of dollars without CDN offload ✗✗

 same formula, opposite verdicts — payload class decides everything

CDN Offload Math

The standard fix, priced honestly:

 WITHOUT CDN:   100% of bytes at internet egress rates from origin
 WITH CDN:      ~90–95% served from edge (hit ratio);
                origin pays only misses + CDN's cheaper bulk pricing

 break-even is immediate for cacheable static content —
 CDNs aren't an optimization for media; they're the accounting structure

Cacheable-vs-uncacheable split drives everything: profile images cache forever; personalized API responses don’t — so their egress has no CDN escape hatch and needs payload discipline instead.

Payload Discipline for Non-Cacheable Traffic

LeverTypical saving
gzip/brotli on JSON/text60–80%
Field trimming (serve what the screen shows)30–70%
Pagination + cursoringcaps worst-case payloads
Protocol choice (binary vs verbose JSON)20–50%
Image formats (WebP/AVIF vs JPEG)30–60%

API design reviews that ask “is this field consumed?” are egress cost control wearing an engineering hat.

The Hidden Internal Bill

User-facing egress gets attention; internal chatter burns silently:

 anti-pattern: microservice A calls B per item in a loop
   10k rps × 100 calls × 1 KB × cross-AZ pricing = real money/month
 fixes: batching, co-location (same-AZ affinity), caching responses,
        event-driven sync instead of polling loops
 
 rule of thumb: if internal bytes exceed user-facing bytes,
 the topology deserves a redesign conversation

Interview Framing

Egress fluency = running one multiplication per traffic class, then landing the consequence (“that volume means CDN-first” / “cross-AZ chatter argues for zone-aware routing”). For media designs, stating the PB-scale number before proposing components demonstrates why the architecture exists. Numbers terminating in decisions — always.

My Private Notes

Notes are auto-saved locally to this device.