Multi-Region Architecture - Complete Deep Dive
Prerequisites: CAP Theorem, Database Replication Used in: Digital Wallet, Payment System, Netflix
What is a Multi-Region Architecture?
A region is a cluster of data centres in one geographic area — Mumbai, Frankfurt, Northern Virginia. Inside a region, machines are a few kilometres apart and talk to each other in under a millisecond. Between regions, they are thousands of kilometres apart and talk to each other in tens or hundreds of milliseconds.
A multi-region architecture runs your system in two or more of these regions at the same time. The hard part is never the servers — you can boot servers anywhere. The hard part is the data: deciding which region is allowed to accept a write, how that write reaches the other regions, what a user sees in the gap, and what happens when a whole region disappears.
Real-world analogy: Think of a retail chain with warehouses in Mumbai and Frankfurt. Keeping stock in both places is easy — you just ship goods. The difficulty is the ledger that says how many units exist. If both warehouses are allowed to promise the last unit to a customer, you have sold the same item twice. So you either nominate one warehouse as the official book-keeper (everyone phones Mumbai before promising anything, which is slow for Frankfurt customers), or you split the catalogue so each warehouse owns certain items outright (fast, but Frankfurt cannot promise a Mumbai-owned item). Every multi-region design is a version of that choice.
The Speed of Light Is Your Real Constraint
Light in a vacuum travels at about 300,000 km per second. Inside glass fibre it travels at roughly 200,000 km per second — about two thirds of that. This is physics, not an engineering problem, and no vendor, protocol or budget changes it.
Mumbai to Northern Virginia is about 12,500 km in a straight line. Real fibre does not go in straight lines — it follows coastlines, existing cable routes and landing stations, so the actual path is roughly 1.5x longer, call it 19,000 km. A round trip (there and back) is 38,000 km.
38,000 km / 200,000 km per second = 0.19 seconds = 190 ms
Add router hops, switching and queueing, and the real-world
Mumbai to Virginia round trip is 200-250 ms.
Compare that with what happens inside a single region:
| Hop | Typical round trip | Notes |
|---|---|---|
| Same rack | under 0.5 ms | Memory and network are both cheap here |
| Same region, different availability zone | 1-2 ms | Safe to do synchronously, several times per request |
| Mumbai to Singapore | 55-70 ms | Already more than most latency budgets allow twice |
| Mumbai to Virginia | 200-250 ms | One of these ruins a 300 ms budget on its own |
The conclusion that matters: if a single user request synchronously waits for another region — a write that must be acknowledged in Virginia before Mumbai replies, a lock held in a global coordination service, a read of a “global” counter — you have added 200 ms or more to that request. You are making a latency decision whether you realise it or not. Most multi-region designs that feel slow in production are designs where somebody added a cross-region hop to the request path without noticing.
A useful rule: cross-region traffic belongs on the replication path, not on the request path. Asynchronous replication happens in the background and nobody waits for it. Synchronous replication happens while the user watches a spinner.
The Four Reasons to Go Multi-Region
People say “we need multi-region” as if it were one goal. It is four, and they pull the design in different directions. Decide which one you actually have before you draw anything.
| Reason | What you are optimising | What it demands |
|---|---|---|
| User latency | Round trip time for users far from your home region | Local reads everywhere, and ideally local writes |
| Disaster recovery | Survive losing an entire region | A warm copy of data elsewhere plus a tested failover |
| Data residency | Legal compliance on where data physically lives | Data that must not leave a region |
| Regional capacity | Headroom when one region runs out of instances or quota | Ability to run the same workload in several places |
Why keeping them separate matters:
- Latency wants your data copied everywhere, close to every user.
- Residency may legally forbid exactly that copying. European personal data that must stay in the European Union cannot be replicated to Virginia to make Virginia reads fast.
- Disaster recovery needs a second copy, but it does not need that copy to serve traffic. A cold standby that you can promote in 15 minutes satisfies DR and costs a fraction of active-active.
- Capacity is about being able to run elsewhere, which is mostly a deployment and configuration problem, not a data problem.
If you only have a DR requirement, active-active is an expensive and risky answer to a question nobody asked. If you have a residency requirement, a single global database is not an option no matter how convenient it is.
Deployment Patterns, from Simplest to Hardest
These are a progression. Each step buys something and costs something. Stop at the first one that meets your requirements.
1. Single region with backups
One region serves everything. Snapshots and write-ahead-log archives go to object storage in another region. Nothing runs elsewhere.
- Consistency: trivially strong — there is one copy.
- Failover: restore from backup into a new region. Hours, and you lose everything since the last snapshot.
- Use when: your users are concentrated in one area and a multi-hour outage is survivable.
2. Active-passive with asynchronous replication
The primary region takes all traffic. A standby region continuously receives changes asynchronously (streaming replication, or a managed cross-region replica). The standby serves nothing until you promote it.
- Consistency: strong in the primary. The standby lags by the replication delay, typically well under a second but unbounded under load.
- Failover: promote the standby. Minutes. You lose whatever was in flight — the replication lag at the moment of failure.
- Use when: DR is the goal. This is the right answer far more often than people admit.
3. Read-local, write-global
Every region has a read replica serving local reads. All writes are routed to the one region that owns writes.
- Consistency: reads are eventually consistent and lag the write region. Writes are strongly consistent because there is still exactly one writer.
- The catch: a user in Mumbai writing to Virginia pays the 200 ms. Worse, they then read from the Mumbai replica, which has not received their own write yet, so their change appears to vanish. This is the read-your-writes problem — fix it by routing a user’s reads to the write region for a short window after they write, or by pinning reads to a replica that has caught up past the version the write returned. See consistency models.
- Use when: read-heavy workload, write latency tolerable, and you want global read speed without conflict handling.
4. Active-active with partitioned write ownership
Every region accepts writes, but only for the records it owns. Each record has a home region, recorded in routing metadata. A write for a Mumbai-owned user that lands in Frankfurt is either forwarded to Mumbai or rejected with a redirect.
- Consistency: strong per record, because each record still has exactly one writer. No conflicts by construction.
- Failover: when a region dies, you reassign ownership of its records to a surviving region. This is the dangerous moment — you must be sure the dead region is really dead and will not come back still believing it owns those records. Ownership changes need fencing tokens or an epoch number so stale writes from the old owner are rejected.
- Use when: you need local write latency and your data partitions naturally by user, tenant or account.
5. Full active-active with conflict resolution
Any region accepts any write. Replication is bidirectional and asynchronous. Two regions can modify the same record concurrently, so the system must merge divergent versions.
- Consistency: eventual, with real conflicts you must resolve.
- Failover: almost a non-event, which is the appeal. Nothing needs promoting.
- Use when: the data model genuinely tolerates merging — shopping carts, collaborative documents, presence, counters, preference blobs. Not money.
flowchart LR
SR["Single region<br/>plus backups"] --> AP["Active-passive<br/>async replica"]
AP --> RL["Read local<br/>write global"]
RL --> AA1["Active-active<br/>partitioned ownership"]
AA1 --> AA2["Active-active<br/>conflict resolution"]
Nothing in that diagram is a service — these are five positions on one axis. Moving right buys shorter failover and lower write latency, and pays for it with weaker consistency and more code you have to reason about.
RPO and RTO, Defined Precisely
Two numbers describe every failover plan. Interviewers ask for them by name.
- RPO — Recovery Point Objective. How much data you are willing to lose, measured in time. An RPO of 5 seconds means that after a disaster, the last 5 seconds of accepted writes may be gone forever. RPO is set by your replication choice.
- RTO — Recovery Time Objective. How long you are willing to be down, measured in time. An RTO of 10 minutes means service resumes within 10 minutes of the failure. RTO is set by your detection, promotion and routing machinery.
They are independent. You can have an RPO of zero and an RTO of an hour (no data lost, but a slow manual promotion), or an RPO of 30 seconds and an RTO of 60 seconds (fast flip, some loss).
| Replication choice | RPO | RTO driver | Cost |
|---|---|---|---|
| Nightly backup to object storage | up to 24 hours | Restore time, hours | Lowest |
| Async replication, standby idle | replication lag, under 1s typical | Promotion plus DNS, minutes | Low |
| Async replication, standby warm and serving reads | same lag | Promotion plus routing, under a minute | Medium |
| Synchronous cross-region quorum | zero | Automatic, seconds | Highest, and every write pays the round trip |
The honest trade: an RPO of zero across regions means a write is not acknowledged until another region has it durably. That is the 200 ms from the physics section, on every write. Systems that claim zero RPO and fast writes are usually either replicating synchronously to a nearby region (Mumbai to Hyderabad, 20 ms, which is a reasonable compromise) or only synchronising a small critical subset of the data.
Why “Active-Active” Almost Always Means Partitioned Ownership
When a team says “we run active-active”, nine times out of ten they mean pattern 4, not pattern 5. The reason is simple: accepting the same write in two places at once destroys the ability to say what the current value is.
Consider a wallet balance of 100, and two concurrent debits of 80, one in each region. Both regions check the local balance, both see 100, both approve. Replication then has to merge “balance is 20” with “balance is 20” and the true answer is that you allowed 160 of spending against 100 of funds. No merge function recovers from that, because the information that was needed — that one of the two should have been rejected — was never recorded anywhere.
Partitioned ownership avoids the problem rather than solving it. Each account has a home region. The rule is enforced at the routing layer, not left to hope.
flowchart LR
U1["User in India"] --> R["Routing layer<br/>reads ownership map"]
U2["User in Germany"] --> R
R -->|owner is Mumbai| MUM["Mumbai region<br/>write owner for IN accounts"]
R -->|owner is Frankfurt| FRA["Frankfurt region<br/>write owner for EU accounts"]
MUM -->|async replication| FRA
FRA -->|async replication| MUM
MUM --> ROM["Read replica in Frankfurt"]
FRA --> ROF["Read replica in Mumbai"]
New components here:
- Routing layer. Looks up which region owns the record being written and sends the request there. Usually an edge service or gateway holding a small, heavily cached ownership map.
- Ownership map. The authoritative record of which region owns which key range, tenant or account. Changing it is the failover action, and it must be changed through a single coordinated path so two regions never both believe they own the same key.
- Read replicas. Each region keeps a local, eventually consistent copy of the other region’s data so reads are always local even when writes are remote.
Conflict Resolution When You Really Do Accept Concurrent Writes
Sometimes the data model genuinely allows two regions to write the same record. Then you need a merge rule. There are three families.
Last-write-wins (LWW). Attach a timestamp to each write; the highest timestamp survives. Cassandra does this by default.
- It is one line of code and it silently loses data. If two users edit the same profile within the clock skew window, one edit disappears with no error and no record that it ever existed.
- It depends on clocks agreeing. Two servers whose clocks differ by 200 ms will disagree about which write was “later”, and a clock that jumps backwards can make an old write beat a new one permanently.
- Use it only where losing one of two concurrent writes is genuinely acceptable — a last-seen timestamp, a cached preference.
CRDTs — Conflict-free Replicated Data Types. Data structures whose merge function is mathematically guaranteed to converge to the same result regardless of the order in which updates arrive. A grow-only counter merges by taking the maximum per replica and summing. An observed-remove set tracks adds and removes with unique tags so a concurrent add and remove have a defined outcome.
- Strong guarantee: no coordination needed, and every replica ends up identical.
- Real cost: you must express your data as one of these types, and the metadata grows. CRDT sets remember tombstones for removed elements. Redis Enterprise, Riak and the collaborative-editing engines behind document editors use these.
Application-level merge. Keep both versions (“siblings”) and let business logic or the user decide. A shopping cart merges by union — if one region added socks and the other added a lamp, the cart has both, which is almost always what the shopper wanted. A document editor shows a conflict and asks.
To merge properly you need to know whether two versions are concurrent or whether one happened after the other. A plain timestamp cannot tell you that; a causal history can. That is exactly the job of vector clocks — they let you say “these two writes genuinely raced” versus “this one already knew about that one, so it wins cleanly.”
| Strategy | Converges | Loses data | Good for |
|---|---|---|---|
| Last-write-wins | Yes | Yes, silently | Presence, cached preferences |
| CRDT | Yes, by construction | No | Counters, sets, carts, documents |
| Application merge | Only if logic is correct | Only by choice | Carts, profiles, anything with business meaning |
| No concurrent writes allowed | Not applicable | No | Money, inventory, bookings |
Routing Users to a Region
Three mechanisms, often stacked.
- GeoDNS. The Domain Name System server answers the same hostname differently depending on where the query came from, mapping Indian resolvers to the Mumbai address. Cheap and universal. It resolves based on the resolver’s location, which is not always the user’s, and the answer is cached for the TTL — Time To Live — so changes propagate slowly.
- Latency-based routing. The DNS provider measures real round trip times from networks to each region and returns whichever is actually fastest, which is not always the geographically nearest. Better than GeoDNS for correctness, same caching caveat.
- Anycast. The same Internet Protocol address is announced from every region, and Internet routing delivers the packet to the nearest announcement. Failover is near-instant because withdrawing the announcement reroutes traffic with no DNS cache to wait for. This is how most content delivery networks and edge platforms work. See load balancing.
The sticky-session trap. Many systems pin a user to one region for the duration of a session — to keep a session cache warm, or because that region owns their writes. After a failover, those pins are wrong. Three failure modes to plan for:
- Session state lived only in the dead region, so every user is logged out at the worst possible moment. Fix: keep session state in a store replicated across regions, or use stateless signed tokens.
- The pin is cached in the client or in a cookie, so clients keep trying to reach a region that is gone until the TTL expires. Fix: short TTLs on routing decisions, plus a server-side redirect when a request arrives at a region that no longer owns the user.
- Traffic flips back and forth between regions as the failed region partially recovers, and a user’s requests alternate between two replicas with different lag, so data appears to flicker. Fix: make failover decisions sticky and manual-to-revert rather than automatic in both directions.
The Hard Parts People Forget
Schema migrations across regions. Your regions are at different replication positions, and a deploy does not land everywhere at once. A migration that adds a non-nullable column will break a region still running old code, and a migration that drops a column breaks replication from a region still sending it. The rule is the same as any zero-downtime migration, applied with a wider window: expand, then migrate, then contract. Add the new column as nullable and deploy code that writes both shapes; wait until every region has that code; only then backfill; only then stop writing the old shape; only then drop it. See deployment reliability.
The global secondary index that cannot be global. A secondary index is a lookup from a non-primary attribute — “find the user with this email”. If your data is partitioned by region but the index must be queried globally, the index itself needs to be either replicated everywhere (so it is eventually consistent and can tell you a stale answer) or queried by fanning out to every region (so it is as slow as your slowest region and fails when a region is down). Uniqueness is the painful case: enforcing “email addresses are globally unique” across regions that accept independent writes requires a single owner for the uniqueness check, which reintroduces a cross-region hop on signup. Many systems accept it there, because signup is rare and users tolerate it.
Idempotency keys must be unique across regions. An idempotency key makes a retried request safe by letting the server recognise it as a duplicate. If two regions generate keys from a local counter, they will eventually generate the same key for different requests, and after replication one real payment gets treated as a duplicate of another and silently dropped. Generate keys with a region identifier baked in, or use an identifier scheme designed for distributed generation. See unique IDs.
If you have never failed over, you cannot fail over. This is the most reliable prediction in this entire page. Untested failover fails on details that are obvious in hindsight: the standby’s connection limit was never raised, a secret existed only in the primary region, the promotion runbook referenced a tool that needs the dead region’s network, nobody had permissions, the capacity to serve 100% of traffic was never actually reserved. Schedule regular exercises that move real production traffic, start with a region that is not your largest, and treat an untested failover plan as no plan.
Data Residency Can Forbid the Design Your Latency Wanted
Data residency rules say that certain data must physically stay inside a jurisdiction. The European Union’s General Data Protection Regulation restricts transfers of personal data outside the EU. India’s payment regulator requires payment system data to be stored in India. Several countries have similar rules for health and government data.
This is a hard constraint, not a preference, and it frequently contradicts the replication your latency design wanted:
- You cannot make European reads fast in Virginia by replicating European personal data to Virginia.
- You cannot use a single global table for a dataset that must not leave one country.
- Your cross-region backup for disaster recovery may need to stay inside the jurisdiction, which means your DR region has to be a second region in the same country.
The design that survives this is usually a region-siloed one: each jurisdiction gets a self-contained stack with its own database, and only a thin, non-personal layer is global — feature flags, product catalogue, aggregate metrics with no individual identifiers. Users do not roam between silos; a European user is served from the European silo wherever they travel, accepting the latency. The silos share code, not data. Ask about residency early, because it eliminates whole patterns, and discovering it after you have built a globally replicated table is an expensive rewrite.
Decision Table
| If your requirement is | Use | RPO / RTO | Main cost |
|---|---|---|---|
| Survive a region loss, downtime tolerable | Active-passive, async replica | seconds / minutes | Idle standby capacity |
| Fast reads worldwide, writes can be slow | Read-local, write-global | seconds / minutes | Read-your-writes handling |
| Fast reads and writes worldwide, data partitions by user | Active-active, partitioned ownership | seconds / seconds | Ownership map and fencing on reassignment |
| Collaborative or mergeable data, must never reject a write | Active-active with CRDTs | near zero / near zero | Merge semantics and metadata growth |
| Money, inventory, bookings | Single write owner per record, always | depends on replication | Cross-region write latency for remote users |
| Legal residency boundary | Region-siloed stacks | per silo | No global view of user data |
Two closing rules worth memorising. First, put the cross-region hop on the replication path, not the request path, unless you have explicitly decided the latency is worth it. Second, a region that accepts writes for a record must be the only region that accepts writes for that record, unless your data type can merge — and money cannot merge.
Common Interview Questions
Q1: What is the difference between active-active and active-passive, in one sentence each?
Active-passive means one region serves all traffic while another holds a continuously updated copy that serves nothing until you promote it — simple, with a failover measured in minutes. Active-active means multiple regions serve traffic at the same time, which in practice almost always means each region owns writes for a partition of the data so that no record ever has two writers, with a failover measured in seconds because nothing needs promoting, only reassigning.
Q2: How do you handle a user who writes in one region and immediately reads from another?
That is the read-your-writes problem, and it is guaranteed to happen with asynchronous replication. Three fixes, in order of preference: return a version token from the write and have the read wait for a replica that has reached that version; or pin that user’s reads to the write-owning region for a short window, long enough to cover typical replication lag; or keep the written value in the client and render it optimistically. What you must not do is let the user see their own change disappear, because they will retry and you will get a duplicate.
Q3: Your primary region goes dark. Walk me through the failover.
Detect, decide, fence, reassign, route, verify. Detect with health signals from outside the failing region, because signals from inside it cannot be trusted. Decide deliberately — automatic failover on a false positive causes two regions to believe they are primary. Fence the old region so any write it later attempts is rejected, using an epoch or token the storage layer checks. Reassign write ownership to the surviving region. Shift routing, which is fast with anycast and slow with DNS because of cached TTLs. Then verify data loss against your RPO, and reconcile anything that was in flight. The RPO loss is real and you should know the number before the incident, not during it.
Q4: Why not just use synchronous replication everywhere and get zero data loss?
Because every write then waits for a cross-region round trip. Mumbai to Virginia is 200 ms or more of pure physics, so a write that was 10 ms becomes 210 ms and any request doing two writes becomes half a second. It also couples availability: if the remote region is unreachable, a synchronous write cannot be acknowledged, so an outage in the standby takes down the primary — the precise CAP theorem trade. The usual compromise is synchronous replication to a nearby region, where the round trip is 10-20 ms, and asynchronous replication to far regions.
Q5: When would you tell a team they do not need multi-region?
When their requirement is disaster recovery and their users are in one place. Multi-availability-zone inside one region already survives a data centre fire, a power failure and most hardware loss, and it costs almost nothing in latency or complexity because zones are 1-2 ms apart. Full region loss is rare. If the business can accept a 30-minute recovery, an async standby plus a tested promotion runbook delivers that at a fraction of the cost of active-active, with none of the conflict resolution, ownership, migration or residency complexity. Multi-region is justified by user latency, legal residency, or a recovery time objective that genuinely cannot be met any other way.
Navigation
| ← Service Discovery | Authentication → |
| All Concepts | HLD Designs |