Multi-region systems and data locality
A second region buys speed, survival and legal room. You pay in money, in lag between copies, and in a failover you must practise.
Updated since you finished it. We changed this lesson after you marked it done. Your progress is kept.
What broke
On 2 November 2023, between 11:44 and 12:01 UTC, a data centre near Hillsboro, Oregon, lost all power. It was called PDX-04. 1
Cloudflare ran its control plane (the dashboard and APIs) and analytics mainly across three data centres in that area. They were built so that the control plane would keep running if any one of them failed. In Cloudflare's words, "The three data centers are independent of one another". 1
The buildings were independent. Some of the software was not. Some services that were meant to survive still used Kafka and ClickHouse clusters that ran only in PDX-04. Some services, mostly for newer products, had not moved to the shared, highly available setup yet. 1
At 13:40 UTC the team chose to fail over to its disaster recovery sites in Europe. The first services came up 3 minutes later. Then the API calls that had been failing all arrived at once, so the team added rate limits. A few newer products did not start properly in Europe. The services that did move were stable by 17:57 UTC. But some log processing stayed down, and every service was back only on 4 November. 1
Two lines from the report stand out. "Throughout the incident, Cloudflare's network and security services continued to work as expected." And: "we had never tested fully taking the entire PDX-04 facility offline." 1 The traffic part was spread across the world. The control part was not.
It happens for real
Cloudflare · 2 Nov 2023Cloudflare outage: one data centre lost powerFor hours, the Cloudflare dashboard and APIs failed, and logs and analytics were down for almost two days, though customer traffic kept flowing. Google Cloud · 12 Jun 2025Google Cloud outage: blank policy fields crashed API checksFor hours, many Google Cloud and Workspace APIs returned 503 errors across the world, touching 76 Cloud products. All incidents tagged “dependencies”The idea in simple words
A cloud region is a group of data centres in one area, such as Mumbai or Frankfurt. Running in more than one region gives you three things:
- Speed. Users near a region get faster answers.
- Survival. If a whole region fails, another can serve.
- Data residency. Some laws say certain data must stay in a country. A later lesson on privacy covers this.
The price is real. You run and pay for two or more copies of everything. Each copy of the data lags behind the others. And the failover that should save you is a rare, risky event that nobody has practised.
The key idea. The network between regions is slow, and sometimes it breaks. So for each piece of data, decide which region owns its writes, and what users see while the copies disagree.
How it works
The speed-of-light floor
ITU's planning value for optical fibre is 5 µs per km, one way. 3 That works out to about 200 km per millisecond. So every 100 km of cable adds about 1 ms to a round trip. No code change can beat this.
Real paths are longer than a straight line. Azure publishes measured median round-trip times between its regions. These are for the 30 days to 30 July 2026, in both directions: 2
| Region | Region | Median round trip |
|---|---|---|
| East US | East US 2 | 8–9 ms |
| East US | West US | 67–69 ms |
| Central India | Southeast Asia | 53 ms |
| East US | West Europe | 83–85 ms |
| Central India | West Europe | 139–140 ms |
| Central India | East US | 198–201 ms |
These are medians. Your slow requests pay more. Now count the round trips. A page that makes 3 database calls in a row, from India to US East, waits about 600 ms before it does any work. Cross-region calls must be few, and never inside a loop.
Active-passive or active-active
In active-passive, one region serves all traffic. The other keeps a copy of the data and waits. Failover is simple to reason about, but you pay for a region that does little, and you only learn if it works on the bad day.
In active-active, every region serves users all the time. Each region is tested by real traffic every day. But now writes can happen in two places, and you must handle conflicts.
The disaster recovery lesson lists the steps in between, like pilot light and warm standby.
Routing users to a region
DNS is the usual tool. Amazon Route 53, for example, can answer with the region that gives the best latency, by the user's location, or by a failover rule that switches from active to passive. 4 DNS answers are cached, so some clients keep using the old region for a while after a change.
Anycast is the other tool: many sites announce one IP address, and the network picks the nearest. See load balancing for how it works. A CDN uses the same idea to serve cached files near users.
Where the writes go
This is the hard part. You have four main choices.
One writer region, read copies elsewhere. Aurora Global Database has one primary region for writes and up to 10 read-only regions. Copies are typically under a second behind. 5 Reads are local and fast. Writes from far away pay the long round trip. All the lag bugs from replication come back, now with bigger numbers.
A home region per user or tenant. Each user's data lives in one region, often the one nearest to them. All their writes go there. A user in Delhi writes to Mumbai. A user in Berlin writes to Frankfurt. No row has two writers, so there are no conflicts. The cost: you need a lookup from user to region, and moving a user is a data migration. The multi-tenancy lesson shows the same idea with cells.
Many writers, conflicts resolved later. DynamoDB global tables accept writes in every region. In the default mode, changes reach other regions "typically within a second or less". 7 If two regions change the same item at once, the one with the latest internal timestamp wins. AWS calls this "last writer wins". 7 The other write is silently gone.
Other surprises follow. A strongly consistent read may return stale data if the item last changed in another region. A conditional write checks only the local copy. A transaction is atomic only in the region that ran it. 7
One logical database with cross-region quorums. DynamoDB also has a strong mode. It runs in exactly three regions: three copies, or two copies and a "witness" that only votes. Each write is copied to at least one other region before it returns. 7 Spanner works in a similar way. Each write needs a majority of five voting copies, one of them in the leader region, so every write crosses at least two regions. 8 No write is silently lost. In DynamoDB, a write that clashes with one in another region fails and must be retried. 7 Every write waits for regions to talk. Spanner advises putting write-heavy work in or near the leader region. 8 This is the PACELC trade, paid on every write.
Conflicts in active-active
Picture a stock count of 5. A buyer in Mumbai takes 1 and writes 4. At the same moment, a buyer in Singapore takes 1 and writes 4. With last write wins, the final count is 4, but two items left the shelf. Neither region saw an error. The quorums lesson explains why timestamps make this worse when clocks drift.
There are three common fixes. Send all writes for one item to one region. Store changes, like "minus 1", that can be added up in any order. Or use the strong mode for the few items that need it.
Failing over and failing back
Step through a region failover. Use Next and Back, or the ← and → keys.
- Active-passive. All writes go to Mumbai. Singapore keeps a copy that is about one second behind, and serves only reads.
- The Mumbai region fails. The writes from its last second never reached Singapore. If you fail over now, those writes are missing.
- First stop the old writer from taking writes. This is fencing. Then promote Singapore to be the writer. Skip the fence, and you risk split-brain.
- Point DNS at Singapore. Clients that cached the old answer move later. Singapore must now carry all the load, plus a flood of retries.
- When Mumbai comes back, do not trust its data as it is. Rebuild it as a copy of Singapore. Then look in its old data for writes that never got copied.
- Failing back is a separate, planned move. Wait until Mumbai has fully caught up, then switch roles at a quiet hour, with no data lost.
Aurora's docs show the real costs. An unplanned failover "can result in a loss of write transaction data" that had not been copied yet. The RPO is "typically measured in seconds". 6 Aurora tries to stop writes in the old region, but this is best effort. Writes may still land there, which gives split-brain. 6 So Aurora asks you to take apps offline first, and to keep DNS cache times short, such as 5 seconds. 6
Failing back is a separate step. With a managed failover, Aurora adds the old region back as a copy. It first tries to snapshot the old data, so you can look for lost writes. Copy that snapshot if you need it longer than the backup retention period. Later you run a switchover, which waits until the copies match, so no data is lost. 6
Capacity matters too. The surviving region must take all the traffic, plus a burst of retries. Cloudflare hit this. When its services came up in Europe, the API calls that had been failing all arrived at once, and it had to add rate limits. 1
Keep regions from sharing fate
Regions only help if they fail alone. A global control plane can tie them together without anyone noticing.
AWS says some global services have their control plane in one region, while their data plane runs everywhere. IAM, Route 53 and CloudFront have their control planes in us-east-1. 9 AWS advises you to keep these control planes out of your recovery path, so that recovery uses only data plane actions. It calls this being statically stable. 9
Shared data can do the same. In June 2025, Google Cloud's Service Control ran in each region, with its own regional datastore. But a bad quota policy "was replicated globally within seconds", and the crash spread with it. 10 Copy config and policy to one region at a time, as safe deploys explains.
Trade-offs
| Design | Conflicts? | Write latency | Data lost on region failure | Use it when |
|---|---|---|---|---|
| One writer region, read copies | No | Far users pay a long round trip. | Yes The last seconds of async writes. | Most apps that go global first for reads or survival. |
| Home region per user or tenant | No Each row has one writer. | Low for users near home. | Yes , for that region's recent writes. | Users or tenants map cleanly to a place. |
| Many writers, last write wins | Yes One write is dropped. | Low everywhere. | Small. Seconds of writes not yet copied. | Data where losing one of two writes at once is fine, like settings or sessions. |
| Cross-region quorum (Spanner, strong mode) | No silent conflicts. A clashing write fails and you retry. | Higher. Every write waits for other regions. How much depends on how far apart they are. | No | Money, stock and unique names, and you accept slower writes. |
Simple rule: start with one writer region and read copies. Move to home regions when far users complain about write speed. Allow many writers only for data you have checked can lose a write.
At work: how a senior uses this
- Ask first: "Which problem are we solving: speed, survival or law?" Each one leads to a different design.
- For every table, write down which region owns its writes and what a conflict does.
- Count cross-region round trips per request, and multiply by the real numbers for your regions.
- Run a failover drill each quarter. Turn off each whole site or region in a test, not one server. Cloudflare had switched off its other two sites in tests, but never the whole of PDX-04, the one that failed. 1
- Before a drill, check that the standby region has quotas and capacity for full load, plus retries.
- List every dependency your failover runbook calls. Remove any that run in only one region.
- Alert on replication lag between regions. It is your RPO, moving in real time.
With AI
What to ask the agent
"Here is our request handler and its database calls. Our users are in India and our database is in US East. Count the sequential cross-region round trips per request, and estimate the latency with a 200 ms round trip."
"We use DynamoDB global tables in two regions. List every write in this service that could conflict if two regions change the same item, and say what last-writer-wins would drop."
"Write a failover runbook for our Aurora global database. Fence writes first, then fail over, then update DNS. Mark every step that calls a control plane in another region."
What to check yourself
- The latency numbers come from your provider's measured tables, not a guess.
- The runbook fences the old writer before it promotes the new one.
- No step in the recovery path needs a console or API that lives only in the failed region.
- Any code that checks then writes, like "is stock above zero?", runs in one region only.
- The test really cuts a whole region, including its queues and caches.
Check yourself
Your progress is saved only in this browser. Export it to keep it safe.
You have finished 5 lessons. Your progress lives only in this browser. Export a copy so you don’t lose it.
Go deeper
Show 10 sources and related lessons
- Cloudflare, “Post mortem on the Cloudflare Control Plane and Analytics Outage” (opens in a new tab)
One data centre lost power. Services built to survive that still depended on it, and the failover to Europe hit a flood of retried API calls. - Microsoft Learn, “Azure network round-trip latency statistics” (opens in a new tab)
Measured median round-trip times between Azure regions, in tables you can search by region. - ITU-T Recommendation G.114, “One-way transmission time” (05/2003) (opens in a new tab)
Table A.1 gives planning values for delay, including 5 µs per km for optical fibre. - Amazon Route 53 Developer Guide, “Choosing a routing policy” (opens in a new tab)
Failover, geolocation, latency and weighted DNS routing, each in one line. - Amazon Aurora User Guide, “Using Amazon Aurora Global Database” (opens in a new tab)
One writer region, up to 10 read-only regions, and replication that is typically under a second behind. - Amazon Aurora User Guide, “Using switchover or failover in Amazon Aurora Global Database” (opens in a new tab)
Failover versus switchover, lost writes, write fencing, split-brain and failing back. - Amazon DynamoDB Developer Guide, “How DynamoDB global tables work” (opens in a new tab)
Writes in every region, last-writer-wins conflicts, and a strongly consistent mode that costs latency. - Google Cloud Spanner documentation, “Regional, dual-region, and multi-region configurations” (opens in a new tab)
How a multi-region Spanner database forms a write quorum across regions, and where to put the leader. - AWS Whitepaper, AWS Fault Isolation Boundaries, “Global services” (opens in a new tab)
Which AWS control planes live in one region, and how to keep them out of your recovery path. - Google Cloud Service Health, “Multiple GCP products are experiencing Service issues.” (12 June 2025) (opens in a new tab)
A regional service read policy data that was copied to every region within seconds.
Real incident: Cloudflare, 2 Nov 2023: Cloudflare outage: one data centre lost power
Real incident: Google Cloud, 12 Jun 2025: Google Cloud outage: blank policy fields crashed API checks
Related: Replication · CAP, PACELC and consistency models · Quorums and leaderless replication · Disaster recovery and backups · Load balancing · Multi-tenancy and noisy neighbours · Safe deploys and config changes
Before this: Database replication and CAP, PACELC and consistency models.
Related lessons: Disaster recovery and backups, Quorums and leaderless replication, DNS and service discovery and CDN and HTTP caching. DynamoDB global tables in more detail: DynamoDB in depth. Case study: the Cloudflare outage.