Sub topic 2
Setting goals: availability, latency, RTO and RPO
Active-active costs more to build and run than a single region. Numeric goals tell you whether the extra cost is justified, and they constrain every later design choice. This chapter shows how to turn "the service should always be up and fast" into numbers you can test.
This chapter assumes you know basic cloud networking and DNS, and that you understand availability and latency as service goals. It also assumes you have used a database and a load balancer.
Four numbers that drive the design
Every multi-region decision traces back to four targets:
| Target | Question it answers | Typical unit |
|---|---|---|
| Availability | What fraction of time, or of requests, succeeds? | Percent, such as 99.95% |
| Latency | How fast do users get a response? | Milliseconds at p50, p95 or p99 |
| RTO (recovery time objective) | How long may the service be degraded or down after a failure? | Seconds or minutes |
| RPO (recovery point objective) | How much recent data may be lost after a failure? | Seconds of writes, or zero |
RTO and RPO describe one failure event. Availability describes the long-run average. A service can meet 99.9% yearly and still violate its RTO in a single bad incident.
Availability as a downtime budget
An availability target is a downtime budget. Over a 30-day month (43,200 minutes):
| Availability | Allowed downtime per month |
|---|---|
| 99.9% | 43.2 minutes |
| 99.95% | 21.6 minutes |
| 99.99% | 4.32 minutes |
| 99.999% | about 26 seconds |
At 99.99%, a human who needs 10 minutes to notice and fix a problem has already exhausted the month. This is the strongest argument for automated failover. Manual runbooks cannot meet a four-nines budget.
Redundancy math and its limits
If two regions fail independently, the service is down only when both are down. For regions with availability A1 and A2, combined availability is 1 - (1 - A1)(1 - A2). Components in series, such as a global DNS layer in front of the regions, multiply instead.
def downtime_minutes(availability, days=30):
"""Minutes of allowed downtime for an availability fraction."""
return (1 - availability) * days * 24 * 60
def parallel(*availabilities):
"""Available if at least one independent replica is available."""
all_down = 1.0
for a in availabilities:
all_down *= (1 - a)
return 1 - all_down
region = 0.999 # one region on its own
global_layer = 0.9999 # DNS or global load balancer, in series
two_regions = parallel(region, region)
end_to_end = global_layer * two_regions
print(f"One region: {downtime_minutes(region):.2f} min/month")
print(f"Two regions: {downtime_minutes(two_regions):.2f} min/month")
print(f"With routing: {downtime_minutes(end_to_end):.2f} min/month")The output is 43.20, 0.04 and 4.36 minutes. Two 99.9% regions look like six nines, but the shared routing layer pulls the total back to roughly four nines. The arithmetic also hides failures that are not independent:
- A bad deployment pushed to every region at once.
- A shared dependency, such as a global identity provider or a single control plane.
- A configuration or schema change replicated everywhere.
- Capacity exhaustion when one region fails and the others cannot absorb its load.
Measure availability from the user's side
Define availability as a service level indicator (SLI) such as "the fraction of valid requests that return a non-5xx response within 1 second". Then set a service level objective (SLO) on it, such as 99.95% over 30 days. Request-based SLIs are better than uptime checks, because a region can answer health pings while failing real traffic. The tutorial returns to this in the observability chapter.
Latency goals and the speed of light
Active-active often has a second motivation besides availability: serving users from a nearby region. Light in fiber travels about 200 km per millisecond, so a round trip costs roughly 1 ms per 100 km of path. A user 5,500 km from the only region pays at least about 55 ms per round trip, before any processing. Real paths are longer than the straight line, so measured values are higher.
State latency goals as percentiles and by user location, for example "p95 under 200 ms for users in Europe and North America". An average hides the slow tail that users notice.
Cross-region distance also shapes writes. If a write must be confirmed by a second region before it is acknowledged (synchronous replication), every write pays the inter-region round trip. Two regions 70 ms apart cannot give a p50 write latency below about 70 ms. Latency and consistency goals therefore pull against each other, which the next chapter covers.
RTO: how fast you recover
RTO is the time from failure to restored service. In a multi-region design it is the sum of delays in a chain:
- Detection: how long health checks take to notice the failure.
- Decision: how long until a routing change is triggered, whether automatic or by a person.
- Propagation: how long clients and resolvers keep using the old answer, such as a DNS TTL.
- Warm-up: how long before the surviving regions serve the shifted traffic at normal quality.
For example, a health check every 10 seconds that needs 3 failures takes 30 seconds to detect. A 60-second DNS TTL adds up to another 60 seconds for well-behaved resolvers, and some clients ignore TTLs. The achievable RTO is therefore about 90 seconds or more, whatever the plan says. If the requirement is 30 seconds, you need different mechanisms, such as anycast or a global load balancer that does not rely on DNS caching, or client-side retries to a second endpoint.
Active-active shortens RTO because the other regions are already serving traffic. Nothing needs to be promoted or started. In an active-passive design, RTO also includes promoting a replica and warming a cold standby, which often takes minutes.
RPO: how much data you can lose
RPO is the maximum acceptable window of lost writes, measured in time. It is set by how data reaches the second region:
- Synchronous replication confirms a write in two regions before acknowledging it. RPO is zero, but every write pays the cross-region latency, and a partition can block writes.
- Asynchronous replication acknowledges locally and ships changes afterward. RPO equals the replication lag at the moment of failure, usually seconds, and unbounded if the link degrades.
RPO is not one number for the whole system. A shopping cart can tolerate losing a few seconds. A payment ledger cannot. Set RPO per data set, and let it decide the replication method for that data.
Putting the goals together
Goals interact, so write them down together and check them for consistency. A small worksheet helps:
| Data or service | Availability SLO | p95 latency | RTO | RPO | Implication |
|---|---|---|---|---|---|
| Product catalog (reads) | 99.99% | 150 ms | under 2 min | 30 s | Async replication, local reads |
| User profile | 99.95% | 200 ms | under 5 min | 5 s | Async, with conflict handling |
| Payments | 99.95% | 400 ms | under 5 min | 0 | Single write owner or synchronous commit |
Look for contradictions. "RPO of zero" with "p95 write latency under 50 ms" across regions 70 ms apart cannot both hold. When goals conflict, rank them for each data set and relax the one with the least business impact.
Finally, check whether you need active-active at all. If the SLO is 99.9%, a manual RTO of 30 minutes and an RPO of five minutes are acceptable, and your users are in one geography, active-passive is simpler and cheaper. Active-active is justified when the downtime budget is too small for manual recovery or when users are spread across continents.
Exercise
A service has a 99.99% monthly availability SLO. Health checks run every 10 seconds and need 3 consecutive failures to mark a region unhealthy. The DNS TTL is 60 seconds. (a) What is the monthly downtime budget in minutes for a 30-day month? (b) What is the approximate worst-case time to shift traffic after a region fails? (c) How many such incidents fit in the budget?
Show answer
(a) 0.0001 × 43,200 minutes = 4.32 minutes. (b) Detection takes 3 × 10 = 30 seconds, and resolver caches can hold the old answer for up to 60 more seconds, so about 90 seconds in the worst case, longer for clients that ignore TTLs. (c) 4.32 minutes is about 259 seconds, so only two incidents of 90 seconds fit (180 seconds) and a third would exceed the budget. The target is tight enough that you should shorten detection and TTL, or use a routing method that does not depend on DNS caching.
Exercise
Why does synchronous replication give an RPO of zero but make it hard to meet a low write-latency goal across regions?
Show answer
A synchronous write is acknowledged only after a second region confirms it, so no acknowledged write exists in only one region and RPO is zero. The confirmation requires a cross-region round trip, so every write takes at least that long. For regions 70 ms apart, no write can finish faster than about 70 ms.