Regional failure and evacuation
Three things a lost region takes
Section titled “Three things a lost region takes”When a region stops answering, three questions come at once. Where do its users go? Can the regions that are left carry them? And what did the region hold that nobody else has? Moving the traffic of a failed region to the others is called evacuating it. The earlier lessons gave each question a part of the answer: the capacity of the regions left, the time to reroute, and the lag of the copies. This lesson puts them together.
Two words describe the outcome. The recovery time objective, RTO, is how long the service may be down before it is served again. The recovery point objective, RPO, is how much recent data may be lost, measured in time. In the lab the first is Average time to serve again and the second is Data at risk (RPO).
Try it: lose North America
Section titled “Try it: lose North America”Start from the default: three regions, Active-active, 8 servers per region. Under Fail a region, choose North America.
Users in North America, Europe and Asia-Pacific reach a service that runs in one, two or three regions. Choose active-passive or active-active, fail a region, and see where its users go, whether the regions left can hold them, how long the switch takes, and what data was not yet copied out. The numbers come from a model with illustrative inputs.
Regions: latency, failover and data at risk
Every number here is model output. The round-trip times, the traffic from each continent and the lag are illustrative inputs, not measurements of any provider.
A write is confirmed first and copied afterwards, so the copy trails by the lag.
- Mean round trip, user to region
- 20 msWith one region: 76 ms
- Each region must carry
- 900 req/s75% of the peak; each region can serve 800 req/s
- Average time to serve again
- —Fail a region to see it
- Data at risk (RPO)
- 2 s of writesThe latest writes, if their region fails
- With 3 regions, users are on average 20 ms from the region that serves them, and the worst-placed group 20 ms. With a single region (the best placed: North America) it would be 76 ms on average and 160 ms for the worst group.
- A region has 8 servers and can serve 800 requests a second. If one region is lost, the busiest region left would have to carry 900 requests a second, 75% of the 1,200 peak.
- Spread evenly, 3 regions need each at least 1/2 of the peak, 50%, which is 600 requests a second. At that size each region runs at 67% in normal times.
- Not big enough: if the wrong region is lost, up to 100 requests a second would not fit and would be refused.
- Replication is asynchronous with a lag of 2 s: the latest 2 s of writes exist only in the region that accepted them.
- Two regions accept writes, so two users can change the same record before either region has heard of the other's change: that is a write conflict.
| User group | Share of requests | Served by | Round trip | One region (North America) |
|---|---|---|---|---|
| Users in North America | 40% | North America | 20 ms | 20 ms |
| Users in Europe | 35% | Europe | 20 ms | 80 ms |
| Users in Asia-Pacific | 25% | Asia-Pacific | 20 ms | 160 ms |
| Mean over all users | 20 ms | 76 ms |
| Region | Load before | Load after | Capacity | Utilisation | State | Writes not yet copied out |
|---|---|---|---|---|---|---|
| North America | 480 req/s | 480 req/s | 800 req/s | 60% | Busy | 96 |
| Europe | 420 req/s | 420 req/s | 800 req/s | 53% | Busy | 84 |
| Asia-Pacific | 300 req/s | 300 req/s | 800 req/s | 38% | Healthy | 60 |
| Region lost | Busiest region left | Utilisation | Does not fit | State |
|---|---|---|---|---|
| North America | 900 req/s | 113% | 100 req/s | Overloaded |
| Europe | 900 req/s | 113% | 100 req/s | Overloaded |
| Asia-Pacific | 780 req/s | 98% | 0 | Saturated |
Users go to the nearest region that is left (active-passive: to the standby). Spread perfectly evenly, the load on each region left would be the peak divided by N − 1, where N is the number of regions. Nearest-region routing is rarely even, so the busiest region carries more.
| Record | Before | Written in North America | Written in Europe | Last-write-wins keeps | A merge keeps |
|---|---|---|---|---|---|
| Customer's first name | Ana | Anne | Anna | Anna · loses the write from North America | Anne / Anna · both versions, for a person to choose |
| Likes counter | 10 | 11 | 11 | 11 · loses the write from North America | 12 · both increments |
| Shopping cart | (empty) | book | lamp | lamp · loses the write from North America | book, lamp · both items |
Last-write-wins compares timestamps taken from each region's clock. If the second region's clock is behind, its later write can look older and lose. A merge rule, such as a conflict-free replicated data type (CRDT), combines the writes instead of dropping one. It suits a counter or a set; for a field like a name nobody can say which value is right, so the versions are kept for a person to choose.
Illustrative values, not benchmarks of any real product.
Model notes
Assumptions
- Users are in three places and send a fixed share of the requests: 40% from North America, 35% from Europe and 25% from Asia-Pacific. Two regions are in North America and Europe; the third is in Asia-Pacific. Every round-trip time in the lab (20 ms to the region on the same continent, 80 to 200 ms between continents) is an illustrative input, not a measurement.
- Every region has the same servers, and each server can serve 100 requests a second. A region is overloaded when it carries more than it can serve. The lab does not model the slowdown that comes before that.
- A health check runs on a fixed interval, and traffic is moved after the chosen number of failed checks in a row. The time shown is the longest this takes. A resolver keeps the answer it was given for up to the TTL, so the time left on a cached answer is spread evenly between zero and the TTL.
- Replication is to one other region. Asynchronous: a write is confirmed before it is copied, and the copy trails by the lag you set. Synchronous: a write waits for the nearest other region to confirm.
Simplifications
- Round-trip time stands in for latency. It leaves out the time a server needs, the number of round trips a request makes (name lookup, connection, TLS, the request itself), and congestion.
- Users go to the region with the lowest round trip in the table. Geographic DNS, anycast or a global load balancer decide by the network and not by the map, and may differ.
- After a failure every request to the failed region fails until its client has moved. There are no retries, and every client honours the TTL. Some resolvers and clients keep an answer longer than the TTL, and the model does not.
- The standby in active-passive mode is idle until it is told to take over. It then needs the promotion time you set and serves at once at full capacity. A cold standby that must also start servers takes longer, and is not modelled.
- The lab loses a whole region. A part of a region (one zone, one service) fails more often and in other ways, and a region can be reachable and still too slow.
- Data at risk is the writes a second that the failed region was accepting, times the lag. The writes that were not copied are stranded in the failed region, not necessarily destroyed: they come back if the region does. A real lag moves around and grows under load.
- The write conflicts are three illustrative records, written in two regions 0.2 seconds apart, before either write reaches the other region. How often real conflicts happen depends on the data, which the model does not have.
- Synchronous replication is modelled as a wait for the nearest other region. Protocols that agree on every write between regions (consensus) cost more round trips and are not modelled, nor is what happens to a write when the other region cannot be reached: it waits, or it is refused.
Parameter values are illustrative. They are not benchmarks of any real product.
Read the table of regions and the sentences under the figures.
- Where do the users go? North America’s users are sent to the nearest region left, Europe. The table shows Europe’s load going from 420 to 900 requests a second. Asia-Pacific stays at 300.
- Can the regions left carry them? Europe can serve 800. It is at 113%, and the lab says that afterwards the regions left cannot hold it all: 100 requests a second are still refused. The fault is not a flaw of the routing. It is the capacity decision of the second lesson, appearing at the worst moment.
- How long are users stranded? 480 requests a second were going to the failed region. The health check takes 30 s, then cached answers take up to 60 s to expire. Clients are served again after 30 s at the fastest, 60 s on average and 90 s at the slowest, and about 28,800 requests fail for the average client.
- What was lost? Data at risk (RPO) reads 2 s of writes, and about 96 writes were not yet copied out of North America:
480 × 0.10 × 2.
Raise Servers in each region to 10. Europe’s load is still 900, and its capacity is now 1,000: 90% instead of 113%. The overflow disappears, and the lab says that afterwards the regions left carry the traffic. The 28,800 failed requests and the 96 writes stay. Capacity decides whether the evacuation works, and the other two figures are set by the checks, the TTL and the lag.
Now choose Asia-Pacific under Fail a region, with 8 servers again. Its 300 requests a second go to North America, the nearest region left, which then carries 480 + 300, which is 780, or 98%. This one fits. Of the three regions, losing Asia-Pacific is the loss that the layout can absorb. A design is judged by the worst loss, not by the average one.
What happens if the standby has to be promoted?
Section titled “What happens if the standby has to be promoted?”Choose Active-passive and fail North America, the primary. Everyone is stranded this time, 1,200 requests a second. The standby in Europe has to be promoted before it can take writes. Time to promote the standby is 60 s by default, and the failover now has two stages: detection takes 30 s, and promotion takes 60 s more. Cached DNS answers expire while the standby is being promoted, so the two waits overlap and the slower decides. Everyone is served again at 30 + 60, which is 90 s, whatever their cache held: the fastest, the average and the slowest are all 90 s. About 1200 × 90, which is 108,000 requests, fail.
Lower Time to promote the standby to 10 s and the picture changes. The fastest is 40 s, the slowest still 90 s because the longest cached answer decides, and the average is 61 s. A promotion shorter than the wait for cached answers is partly hidden by it. How fast a standby can be promoted depends on the data store. Aurora Global Database documents promoting a secondary region to take reads and writes in less than a minute, and AWS says that for an RDS read replica other than Aurora the promotion takes a few minutes and includes a reboot. The lab’s 60 s is a setting to explore.
The standby is also short of capacity with 8 servers: it must carry 1,200 against 800, so 400 requests a second are refused. Raise Servers in each region to 12, as the second lesson sized an active-passive layout, and it fits at 100%.
There is a kinder case. Under Fail a region, choose Europe in this layout. Europe is the standby, and it carried no traffic. The lab says no user notices, and Average time to serve again says there is nothing to move. But there is one region fewer to fall back on.
A planned move is different from a failure. AWS describes a switchover for a healthy Aurora global database: it relocates the primary region to a secondary with no data loss, for planned work such as rotating regions. Failover is the separate mechanism for recovering after an outage in the primary region. A planned move starts from a healthy primary, and a failure starts from whatever the copies hold.
Data: what the strand costs
Section titled “Data: what the strand costs”Back to the default and North America lost, now with Copying data to another region set to Synchronous. Data at risk (RPO) reads None, and every write waits an extra 100 ms. The 28,800 failed requests are unchanged: synchronous replication saves the data and not the time. With active-passive and the primary lost, asynchronous replication strands 1200 × 0.10 × 2, which is 240 writes, since all the writes were made in one region.
Whether that is acceptable is a business decision, written as numbers. An RTO of 90 s and an RPO of 2 s mean: for a minute and a half after a regional failure users see errors, and for two seconds of writes we have no copy. If the answer is no, the levers are known: faster checks and a shorter TTL for the first, synchronous copies or a smaller lag for the second, and each costs something the earlier lessons showed.
Rehearse it
Section titled “Rehearse it”A failover path is used rarely, so it is the part of the system least likely to work. AWS’s whitepaper is firm that a disaster recovery strategy should be assessed and tested regularly, and that with active-active there is no failover as such: testing focuses on how the workload reacts to the loss of a region. Is traffic routed away from the failed region? Can the other regions handle all the traffic? Those are the two questions the lab answers with its tables. DynamoDB global tables integrate with AWS Fault Injection Service, which can simulate the isolation of a region by pausing replication to and from one replica, to test error handling and the shift of traffic.
The whitepaper makes one more point that applies to every layout here. It divides a service into a data plane, which delivers the real-time service, and a control plane, which configures it, and says that for maximum resilience, failover should use only data-plane operations, because data planes typically have higher availability goals. A failover that has to call a console or an API of the region that has just failed is not a failover. For manual failover, the whitepaper’s example is a Route 53 health check used as a switch you control.
- A lost region takes three things: its capacity, which the others must replace; the time to reroute; and the writes not yet copied.
- In the lab, losing North America sends 480 requests a second to Europe, which carries 900 against a capacity of 800: 100 requests a second are refused. With 10 servers per region it fits, at 90%.
- Users are served again after 30 s at the fastest, 60 s on average and 90 s at the slowest, and about 28,800 requests fail. At 10% writes and a 2 s lag, 96 writes are at risk, and none with synchronous copies.
- Active-passive adds the promotion: 90 s for everybody with a 60 s promotion, and 108,000 failed requests. Losing the standby moves nobody, and leaves no fallback.
- Rehearse the loss of a region, check that the other regions can carry everything, and keep the failover path independent of the region that failed.
Your progress
Built by GhaziAlibi.
© ShardCraft. All rights reserved.