Menu

Earn Premium with Referrals

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

See how it works and start inviting friends.

Global Consistency
HLD

Global Consistency

What 'consistent' means across oceans — the guarantees available and their true costs.

The Consistency Menu Across Regions

 STRONG (linearizability): every read sees the latest write,
   globally, instantly. 
   cost: cross-region coordination on EVERY operation.
   writes pay RTT; reads often too. region loss = stall.
   
 SEQUENTIAL: each client sees own writes in order;
   others may lag but never reorder per-writer.
   achievable with home-region writes + sequencing.

 EVENTUAL: replicas converge eventually.
   cheapest; users see staleness windows.

 READ-YOUR-WRITES: your OWN writes visible to you.
   the pragmatic middle everyone actually needs for UX.

The Cost of Strong at Distance

 spanner-class systems achieve global strong consistency:
 - TrueTime/atomic clocks bounding uncertainty
 - Paxos/Majority quorum across regions per write

 price tag:
   every write: waits for QUORUM across continents (~100ms+)
   availability coupling: need majority REGIONS alive to commit
   throughput ceiling: serialization points exist

 worth it for: inventory reservation, financial ledgers,
 identity/permissions — correctness-critical cores.

 overkill for: posts, likes, preferences, analytics —
 eventual with UX mitigation is correct engineering there.

The Pragmatic Architecture Pattern

 TIER the consistency by data criticality:

 ┌─────────────────┬──────────────────────────────┐
 │ STRONG          │ payments, stock, permissions  │
 │ (quorum/sync)   │ small hot core                │
 ├─────────────────┼──────────────────────────────┤
 │ HOME-REGION     │ user-owned content            │
 │ + RYW           │ single-writer model           │
 ├─────────────────┼──────────────────────────────┤
 │ EVENTUAL        │ feeds, counts, recommendations│
 │                 │ bulk of everything            │
 └─────────────────┴──────────────────────────────┘

 most "we need strong consistency" designs actually mean
 "we need read-your-writes on THIS flow" — much cheaper.
 interrogate requirements ruthlessly here.

Delivering Read-Your-Writes Globally

 without paying strong-consistency prices everywhere:

 □ STICKY WINDOW: after write, route user's reads to
   home/writer region for N seconds (session affinity)
 □ VERSION TOKENS: response carries watermark;
   replicas compare & hold/wait if behind ✓ (elegant)
 □ WRITE-THROUGH UI: command responses carry the new state;
   client renders it; replicas catch up unnoticed
 
 combined with eventual replication elsewhere = users
 experience consistency where they can FEIT it,
 pay distributed-coordination costs only where REQUIRED.

Interview Framing

“Does this global design give strong consistency?” scored shape: define the tiers precisely, tier-by-data table built live, cost arithmetic for strong-at-distance (RTT-per-write, quorum-availability coupling), RYW-delivery mechanics named, requirement interrogation demonstrated (“which flows actually need it?”). The reflex that wins: consistency is a PER-FEATURE budget, not a system-wide setting.

My Private Notes

Notes are auto-saved locally to this device.