System Design · Concept Library · Free article
Geo-Replication: Keeping Data Fast on Two Continents at Once
A single global voting majority makes every far-away write cross an ocean, about 300 ms of distance no faster server can remove. Give each record a home region, pin the replicas that vote on it there so most writes stay local, then replicate across regions for reads.
Geo-replication is keeping copies of your data in more than one region and deciding, per record, which region owns its writes. A quorum keeps a shard consistent — but if the copies that must vote on a write are scattered across the globe, every write waits on a cross-region round trip. Tokyo → US-East is ~150 ms each way at the speed of light: ~300 ms of pure distance on a save that nothing is wrong with, and no bigger server beats it. The fix is regional data ownership — give each shard (or record) a home region and pin its leader and voting majority there, so a write only needs a local majority and commits in ~35 ms. Then you geo-replicate: stream each region’s writes out to read-only copies in the other regions so a reader anywhere hits a nearby one. The price is replication lag across the ocean (a distant reader can be a beat stale) and a new wound — once a record has a home, a traveling user or globally-shared data can be written in two regions at once, and pinning gives no rule for which write wins. That conflict is a later chapter; the honest shape of going global is this: a globally-consistent write is a globally-slow write, so you choose, per workload, where data is owned.
Tokyo hits Save and waits a third of a second — for nothing
Mei runs a bakery in Tokyo and edits her Hatch link-in-bio page every morning. Last quarter Hatch stood up a full APAC region — app servers and database copies a few kilometres from her — so her page loads instantly now. But when she taps Save, the spinner turns for about a third of a second before it settles. Every dashboard is green. The shards are healthy, the quorum is healthy, no node is down. Nothing has failed. It’s just far.
Here’s the catch. Back in the last chapter we made each shard safe by requiring a majority of its copies to vote yes before a write counts — that’s what stops two leaders and lost writes. But that voting majority happens to live in US-East. So when Mei saves, her write flies across the Pacific, waits for a majority of copies 9,000 miles away to confirm, and flies back — about 300 ms of pure geography on every save, even though there’s an identical, idle copy of her data sitting in a rack one city over.
Watch the exact same Tokyo save commit in two worlds — one where the voting majority is global, one where it lives in Mei’s region:
The interactive version of this example is available when JavaScript loads.
That gap — ~300 ms versus ~35 ms — is the whole chapter. No faster machine closes it; only moving the vote closer does. The rest of this page is how you do that without giving up the safety the majority bought you, and what it costs.
Half of this you already know — the new half is the write
A region is a cluster of datacenters in one part of the world — US-East, APAC, EU — far enough apart that a round trip between two of them is measured in hundreds of milliseconds, not single digits. Geo-replication is keeping copies of your data in more than one region so users everywhere have something nearby to talk to. It comes in two halves, and you’ve already built the easy one.
The easy half is reads. Back in Read Replicas you learned to keep a read-only copy of the database near far-away readers, so their reads resolve locally instead of crossing an ocean — and to live with the small replication lag that async copies run behind by. Put one of those copies in each region and global reads are solved. That page owns read-scaling and lag; this one leans on it and moves on.
So geo-replication is really two decisions stacked: (1) where does each record’s write authority live (so writes are fast for the people who make them), and (2) how do the other regions get read-only copies (so reads are fast for everyone else). Get the first wrong and no amount of the second saves you — Mei’s save is slow precisely because her data’s write authority sits on the far side of the planet. Fix that first.
Regional data ownership: give each record a home
The fix has a plain shape: give each shard a home region, and pin its leader and voting majority to that region. Now a write only has to convince copies that sit in the same region as the writer — a local majority confirms in ~35 ms, and the cross-region copies drop to background replication that nobody waits on. Mei’s bakery data is homed in APAC, so her save never touches the ocean; a creator in Ohio is homed in US-East, so theirs doesn’t either. Each record’s home region is its source of truth.
The whole game is picking the right home. Home a shard where most of its writers actually live, and most writes stay local; home it by accident (say, all shards in US-East because that’s where you started) and everyone else pays the ocean tax. Drag the homes around and watch local-write share and average commit time move:
The interactive version of this example is available when JavaScript loads.
Notice what you did not give up. The majority rule is intact — a write still needs a majority of its copies to vote yes, so you still can’t get two leaders or a lost write. You only moved the voters into the writer’s region so the vote finishes locally. The Raft leader and its quorum from the last chapter didn’t change; they just got a home address. Same safety, minus the ocean.
Who is allowed to accept a write?
Once data spans regions, systems differ on one question: how many regions may accept a write to the same record? That single choice defines the three multi-region topologies you’ll meet, from the simplest and safest to the most powerful and most dangerous.
| Topology | Who accepts writes to a record | Consistency story | The catch |
|---|---|---|---|
| Single-leader, region-homed (what we just built) | Exactly one region — the record’s home — owns its writes; other regions hold read-only copies | Strong for writes (one authority + local majority); reads elsewhere are eventually consistent | A writer outside the home region still crosses the ocean to write — you optimise the home for where writers are |
| Multi-leader / active-active | Every region can accept writes to the same record locally | Fast writes everywhere, but two regions can change the same record at once | Write conflicts — the wound this chapter opens; needs a merge rule (a later chapter) |
| Global synchronous (e.g. Spanner-style) | One logical authority, but every write is confirmed across regions before it returns | Strong and global — a write is current everywhere the instant it commits | Every write pays the cross-region round trip — the ~300 ms tax, on purpose, for correctness |
Writes are local now — where do the reads come from?
Homing fixed Mei’s writes. But her page is read by fans everywhere — and a fan in New York opening her Tokyo-pinned page has a choice to make on their behalf. You could always read from the data’s home-region leader, so the fan sees the freshest possible version. It’s correct to the millisecond… and slow: that read flies across the Pacific to APAC and back, the exact ~300 ms tax you just escaped on writes, now charged on every cross-region read. A globally-consistent read is a globally-slow read.
The better answer is the one you already know from read replicas, stretched across regions: stream each home region’s writes out to read-only copies in every other region, and serve each read from the nearest copy. Now the New York fan reads a US-East copy of Mei’s page — local and instant — while APAC keeps replicating its writes outward in the background. Flip the reader and the strategy and watch latency and freshness trade places:
The interactive version of this example is available when JavaScript loads.
Replication lag, now measured across an ocean
Serving reads from a nearby copy is exactly what keeps them fast — but those copies trail the home region by the time it takes an update to cross the network. That gap is replication lag, and you met it in a single datacenter on the read-replica page. Across an ocean it’s the same idea with bigger numbers and a nastier tail: usually tens of milliseconds, but under a write burst or a congested inter-region link it stretches to seconds. Drag the pressure and watch the staleness window a distant reader sees:
The interactive version of this example is available when JavaScript loads.
So the honest description of what you built is fast everywhere, eventually consistent: a creator edits their page, and for a fraction of a second after, distant readers can still see the old version before the update lands. For a bio or a like-count that’s invisible and fine. For a "did my change actually save?" read it’s wrong — so you route that read to the home region and let everything else enjoy the local copy. You decide, per workload, how much lag you can stomach — that’s the recurring shape of going global, and the sibling consistency-vs-locality page turns it into a decision framework.
Three failures — and the worst looks like perfect health
A cluster that spans continents fails in ways a single-region one never could. Three are worth feeling one at a time — the correct write that’s unbearably slow, the local read that’s quietly stale, and the traveling user written in two places at once.
The correct-but-slow global write
- What you see: every APAC save spins ~300 ms during the morning rush. The cluster is green, the quorum is green, no node is down.
- Why: the voting majority for those shards lives across the Pacific, so each write waits on the ocean round trip before it can return — nothing failed, distance is just the floor.
- The tell: latency that’s flat and high regardless of load. A load problem climbs with traffic; a distance problem sits pinned at the physics floor no matter the QPS. If scaling the slider doesn’t move it, it’s geography, not capacity.
- The fix: pin the majority to the writer’s region (what this page is about) — the ocean crossing moves to background replication.
The stale local read
- What you see: a creator in Tokyo updates their bio; a fan in London refreshes and sees the previous bio for a moment (milliseconds, seconds at worst) before it quietly corrects itself.
- Why: the London read never crossed the ocean — it hit a nearby copy the home region hadn’t finished updating yet. That’s replication lag doing exactly what it does.
- The tell: staleness that’s bounded and self-healing — it fixes itself once the copy catches up. If it never heals, that’s a broken replication stream, a different bug.
- The fix: it’s a trade, not a break — accept it for tolerant reads; route must-be-current reads to the home region; alert when lag exceeds your per-workload budget.
The third one isn’t a slowdown or a stale copy — it’s a genuine wound that regional ownership opens. Step through it:
The interactive version of this example is available when JavaScript loads.
Measuring & operating a multi-region system
- Local-write ratio is the headline. What share of writes commit on a local majority versus crossing a border? A low ratio means your homes are placed wrong — data is homed away from its writers. This is the number regional data ownership exists to move.
- Cross-region replication lag, per link. Track it in both seconds-behind and log-bytes-behind, for every region pair. A climbing lag is your early warning that a link (or a write burst) is backing up and distant reads are going stale.
- Cross-region write rate. How often is a record written from outside its home region? A rising number is the traveler/globally-shared problem showing up — the conflict risk you haven’t solved yet — and a signal you may need active-active for that data class.
- Where each read was served. Attribute reads to home-leader vs local-replica. A surprise spike in home-leader reads means someone is paying the ocean tax by accident — often a "must be current" flag applied too broadly.
- Egress $ between regions. Cross-region replication is billed bandwidth. Watch it; it’s the line item that makes a second region "not free".
What it costs, and when not to go multi-region
Going multi-region roughly doubles your storage (a full copy per region), adds steady cross-ocean replication traffic (real egress dollars), and — the expensive part — multiplies the reasoning: every piece of data now has a "where does it live and who can write it" question attached. It’s the right tool when your users are genuinely spread across the globe, or a law forces data to stay in-region. It’s the wrong reflex when:
Signs you don’t need multi-region (yet)
- Your users are concentrated in one region. A far-away minority is better served by a CDN and read replicas than by a whole second write region. Distance hurts reads first; fix that half before the write half.
- You can’t articulate a home for your data. If ownership is genuinely global and every record is written from everywhere, single-leader homing doesn’t fit — and multi-leader’s conflict tax may cost more than you save. Be honest about your write pattern first.
- A region outage isn’t in your risk budget. Multi-region buys survival of a whole-region failure; if a few hours of single-region downtime is acceptable, you may not need to pay for it.
- You haven’t exhausted one big region. One well-sized region with replicas and caching carries enormous load. Reach for multi-region on a measured latency-or-compliance need, not by reflex.
How the real systems do it
Every one of these is a variation on "where does a record’s write authority live, and how do copies reach the other regions." CockroachDB and Google Spanner make regional data ownership a first-class SQL feature — table/row locality settings and geo-partitioning pin each row to a home region, with super regions / data-domiciling for GDPR-style residency (Spanner leans on synchronised clocks to keep it globally strong). Amazon DynamoDB Global Tables are the active-active end: every region accepts writes and conflicts are resolved last-writer-wins by timestamp (eventual by default, with a stricter multi-region-strong mode). Aurora Global Database is closer to what we built — one primary region owns writes, others are fast read replicas with cross-region streaming and quick promotion. Apache Cassandra offers per-request tunable consistency across datacenters (LOCAL_QUORUM is literally "a majority in my region" — regional data ownership as a read/write setting). Different products, one map: pick where writes are decided, replicate the rest for reads.
The two routing decisions
The whole architecture reduces to two routing rules the app (or a region-aware router) applies on every request — send a write to its home region’s leader, and send a read to the nearest copy unless it must be current:
Region-aware routing, in pseudocode
- Find the home.
region = homeRegionOf(shardFor(recordKey))— the consistent-hashing ring maps the key to a shard, and the shard carries ahome_region. - Route the write there.
write → leader(region)— the write commits on a local majority insideregion; the ack returns without crossing a border. Background replication ships it outward afterward. - Route reads by freshness need.
read → mustBeCurrent ? leader(home_region) : nearestReplica(callerRegion)— a "did my change save?" read goes to the home leader; everything else hits the local copy and accepts the lag. - Pin the recent writer briefly (the read-your-own-writes carry-over): for a few seconds after someone writes, route their reads to the home region so they always see their own change, even from afar.
- Make "must be current" a deliberate flag, not a default — every read that carries it is a read you’re choosing to pay the ocean for.
Pitfalls
- One global majority per shard. The original sin: a write waits on votes across the world. Symptom is latency that’s flat-and-high regardless of load. Fix: home the majority near the writer.
- Homing data away from its writers. A home region only helps if it’s where the writes come from. Pinning every shard to US-East because that’s where you started leaves everyone else paying the ocean tax — measure the local-write ratio.
- Reading the home leader by habit. Routing every read to the authoritative region throws away the whole point of local copies. Read nearest by default; go to the home leader only for must-be-current reads.
- Treating replication lag as zero. Distant copies trail the home, sometimes by seconds under load. Code that assumes a write is instantly visible everywhere will flash stale data. Monitor lag; budget for it per workload.
- Sliding into accidental active-active. The moment two regions can write the same record, you have conflicts you have no rule for. Keep one home per record until you’ve deliberately adopted a conflict-resolution strategy.
- Forgetting the egress bill. Cross-region replication is metered bandwidth. A chatty replication stream between continents is a line item that surprises teams who modelled only storage.
Best practices
- Home each record where its writers live — the single lever that makes the common write local. Revisit it as your user base shifts.
- Keep the majority in-region — pin a shard’s leader and its voting quorum to the home region so the vote never crosses a border.
- Replicate for reads, read nearest — a copy in every region, served locally; route only must-be-current reads to the home leader.
- Make freshness an explicit choice — a per-read "must be current" flag, sparingly used, so paying the ocean for a read is always deliberate.
- Monitor lag and local-write ratio — the two numbers that tell you whether your placement is right and your reads are honest.
- Stay single-home until you truly need active-active — adopt multi-leader (and its conflict rules) on purpose, for a specific globally-shared data class, not by drift.
Rapid-fire cheat-sheet (intern → principal)
- "Why is a write slow for a user far from the database, even when nothing is broken?"
- A write isn’t safe until a majority of its copies confirm it. If some of those copies live in another region, the write waits on a cross-region round trip — ~150 ms each way across the Pacific, the speed-of-light floor. No faster server beats distance; you move the voters closer instead.
- "What is regional data ownership / geo-partitioning?"
- Give each shard or record a home region and pin its leader and voting majority there, so a write only needs a local majority (~35 ms) instead of a global one. Same majority safety — you moved the voters into the writer’s region, not removed the rule.
- "How do reads stay fast for users in other regions?"
- Geo-replicate: stream each home region’s writes to read-only copies in the other regions and serve each read from the nearest one. The price is replication lag — a distant copy trails the home by ms to seconds — so must-be-current reads go to the home leader, everything else reads local.
- "Single-leader region-homed vs active-active — when each?"
- Region-homed single-leader when most records are written from one place (fast, safe, no conflicts) — accept eventual reads elsewhere. Active-active when data is genuinely written from everywhere and you can tolerate/resolve conflicts (last-write-wins, CRDTs). Global-synchronous (Spanner) when a write must be correct everywhere and you’ll pay the round trip for it.
- "What new problem does giving data a home region create?"
- A traveling user or a globally-shared record can be written in two regions at nearly the same instant — two conflicting versions with no built-in referee. A home is an address, not a rule for which write wins. Resolving that (LWW / version vectors / CRDTs) is a separate, harder problem.
- "How would you decide where to place a piece of data?" (the principal one)
- Follow the writers and the law. Home a record where the bulk of its writes originate so the common write is local; where a residency law applies, the home is dictated (GDPR domiciling). Then classify its reads by freshness need. It’s per-workload: a globally-consistent write is a globally-slow write, so you only pay for consistency where the workload truly needs it.
The takeaway
By GOAT Engineer. Back to Concept Library. Privacy Policy · Contact.