Menu

Earn Premium with Referrals

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

See how it works and start inviting friends.

Data Locality
HLD

Data Locality

Keeping data near its users — the latency physics and homing strategies behind regional architecture.

The Physics You Can’t Negotiate With

 speed of light sets floor latency:

 Tokyo → Virginia:      ~170ms RTT (fiber path reality)
 Frankfurt → Virginia:  ~90ms
 within-region AZ-AZ:   ~1–2ms

 a page needing 10 sequential cross-region round trips:
 10 × 100ms = 1 full second of pure transit. before compute.

 LOCAL data + local compute: sub-10ms interactions.

 locality isn't an optimization; at global scale it's
 THE product-feel difference. users feel distance directly.

The Homing Model

 assign each datum a HOME region:

 user profile:        home = signup region (EU-user → EU)
 their posts/likes:   home follows profile home
 sessions:            region-local by construction

 [EU store: EU-users' data]──replicate──►[US][APAC read-only]
 [US store: US-users' data]─────────────►[EU][APAC read-only]

 WRITES go home (single-writer = no conflicts);
 READS served locally from replicas.
 = active-active's pragmatic pattern, applied per-entity.

Read Paths vs Write Paths

 LOCAL reads (the common case):
   profile views, feeds, product pages → regional replicas ✓
   
 WRITE-home routing:
   user edits → route to home region → replicate out
   
 CROSS-HOME reads:
   EU-user views US-friend's post:
     option A: read US replica in EU (laggy-tolerant content)
     option B: async fan-out — friend's post ALREADY replicated
               into EU follower timelines at write time ✓
   social platforms choose B aggressively: pre-computed local
   copies of everything you'll want to see.

 design instinct: move DATA to readers ahead of time;
 don't drag readers to data across oceans.

When Locality Breaks

ScenarioConsequenceMitigation
User travels regionsfar-from-home writesaccept write latency OR re-home tooling
Region failurehomes strandedfailover re-homing runbooks
Cross-region features (shared docs)no single home fitspartition per-OBJECT or accept one-region latency for that feature
Global uniqueness needscross-region coordinationpre-allocated ID ranges / UUIDs
 RE-HOMING: migrating a user's data between regions
 (they moved to Tokyo permanently). background copy +
 cutover + reverse-sync — treat as a project feature,
 not an afterthought.

Interview Framing

“Global collaboration app feels slow for Asia-Pacific users” scored shape: light-latency arithmetic first, homing model proposed (writes-home/reads-local), replication topology drawn, cross-home interaction pattern chosen (fan-out vs remote-read), travel/re-homing edge acknowledged. Data locality questions test whether candidates think in PHYSICS first and architecture second — start with milliseconds.

My Private Notes

Notes are auto-saved locally to this device.