Sub topic 13
Capacity planning and surviving the loss of a region
This chapter assumes you know how health checks and DNS failover move traffic between regions, and what RTO and RPO mean. It covers a question those mechanisms leave open: when a region fails, can the remaining regions carry its load?
Failover only works if the survivors have room. If they don't, a regional outage turns into a global one. The healthy regions overload, their health checks fail, and traffic bounces between regions that are all saturated.
The headroom rule
Suppose you run N regions that share traffic equally. Total peak load is L. You want the survivors to stay at or below a target utilization u after one region is lost. A common choice is 60 to 75 percent, which leaves room for bursts.
After a loss, each survivor carries L / (N − 1). So each region needs capacity:
C ≥ L / ((N − 1) × u)
In normal operation each region then runs at u × (N − 1) / N utilization. The table below uses u = 0.7.
| Regions (N) | Normal utilization per region | Capacity bought per unit of load |
|---|---|---|
| 2 | 35% | 2.0x |
| 3 | 47% | 1.5x |
| 4 | 52.5% | 1.33x |
| 5 | 56% | 1.25x |
Two regions is the most expensive layout per unit of protection. Each region must be able to take 100% of the traffic, so half your fleet is idle most of the time. More regions lower the overhead, but they raise data replication and operational cost. Chapter 16 covers that trade-off.
Uneven traffic and the worst-case region
Real traffic is rarely equal. A region serving 60% of users is the dangerous one to lose, and the capacity you need depends on where its traffic lands. The script below tries each single-region loss. It assumes the lost load moves to the survivors in proportion to their current load. Each region must then be sized for the worst case it can face.
def required_capacity(load, target_util=0.7):
"""load: peak requests per second by region.
Returns the capacity each region needs to survive the loss of any one other region."""
need = {}
for lost in load:
remaining = {r: v for r, v in load.items() if r != lost}
remaining_total = sum(remaining.values())
for region, own in remaining.items():
after = own + load[lost] * own / remaining_total
need[region] = max(need.get(region, 0), after / target_util)
return {r: round(need[r]) for r in load}
load = {"us-east-1": 6000, "eu-west-1": 3000, "ap-south-1": 1000}
print(required_capacity(load))
# {'us-east-1': 12245, 'eu-west-1': 10714, 'ap-south-1': 3571}The three regions need about 26,500 requests per second of capacity to serve 10,000 at peak. The largest region sets the cost. Losing us-east-1 is the worst case for eu-west-1. Losing eu-west-1 is the worst case for us-east-1.
Proportional redistribution is an assumption. Latency-based routing sends users to the next-closest region, which may not be proportional. Use real traffic data, such as which region absorbs which users, when you replace that line.
What "capacity" must cover
Compute is the easy part. A region is only as strong as its tightest resource, and the survivor has to absorb the extra load on all of these:
- Database throughput. Writes may stay local, but a survivor now handles the failed region's writes too. Check write IOPS, connection limits, and the replication apply rate.
- Connection pools and file descriptors. Extra clients arrive at once and can exhaust pools before CPU rises.
- Caches. Users from the failed region have cold entries in the survivor's cache. Origin load spikes until the cache warms.
- Downstream dependencies. Payment providers, search clusters, and third-party APIs have their own rate limits.
- Account and service quotas. Cloud limits such as instance counts, load balancer capacity, and API rate limits apply per region. A quota raised in one region does not carry over to the others.
- Replication backlog. When a region goes down, queued events may arrive in a burst, or the failed region may need to catch up on recovery.
Pre-provisioned or autoscaled
You can hold the headroom as running capacity, or you can rely on autoscaling to create it after the failure.
| Approach | Strength | Weakness |
|---|---|---|
| Pre-provisioned headroom | Absorbs failover immediately and is predictable | Pays for idle capacity all the time |
| Autoscaling on demand | Cheaper in normal operation | New instances take minutes to start, and the cloud may lack capacity in that region at that moment |
| Hybrid: warm pool plus autoscaling | Balances the two | Needs tuning and regular testing |
Compare the autoscaler's reaction time with your RTO. Instances need time to launch, pass health checks, and warm up. During that time the survivors are overloaded. Autoscaling cannot be the only protection when the failover shifts 50% of traffic in a minute.
Capacity reservations help with the "cloud has no instances" risk. During a large regional outage many customers fail over at once, and on-demand capacity in the neighboring region can run short.
Surviving the overload window
Even well-sized regions see a brief spike while traffic shifts and caches warm. Plan for degradation, not only for scale.
- Load shedding. Reject low-priority requests (batch jobs, analytics, background sync) with a clear
503and aRetry-Afterheader, so critical traffic stays within capacity. - Rate limits per client or tenant. Stop one noisy client from taking the headroom.
- Graceful feature degradation. Turn off expensive features such as recommendations or search suggestions while the system stabilizes.
- Retry control. Clients that retry immediately multiply the load. Use exponential backoff with jitter, and make operations idempotent so retries are safe.
- Gradual traffic shift. Weighted routing and connection draining move users over in steps, so cold caches fill gradually.
Failback is also a capacity event
When the failed region returns, sending traffic back all at once recreates the problem in reverse. The recovered region has cold caches, possibly stale data, and a replication backlog. Bring it back in steps:
- Confirm data is caught up (replication lag near zero).
- Warm caches and connection pools with synthetic or small amounts of real traffic.
- Raise routing weight in steps, for example 5%, 25%, 50%, 100%, and watch error rates and latency at each.
Common mistakes
- Sizing for average load rather than peak load, including seasonal peaks.
- Treating the target as "survive one region" while a shared dependency, such as a global control plane or a single-region database, remains a hidden single point of failure.
- Counting capacity that exists on paper but is blocked by quotas.
- Never testing it. The numbers are a model, and only a game day shows whether the survivors really hold at 100% failover load. Chapter 14 covers failure testing.
- Ignoring correlated failures. Two regions in the same provider may share a failure cause. If your requirement is to survive two simultaneous losses, use N − 2 in the formula, and expect a very large cost.
Exercise
You run three regions with equal load, 9,000 requests per second in total at peak. Your target utilization after losing one region is 80%. How much capacity does each region need, and what utilization does each run at in normal operation?
Show answer
After losing one region, each survivor carries 9,000 / 2 = 4,500 requests per second. Capacity needed per region is 4,500 / 0.8 = 5,625 requests per second. In normal operation each region carries 3,000 requests per second, so utilization is 3,000 / 5,625, about 53%.
Exercise
Your autoscaler needs about 6 minutes to add instances, and your RTO is 2 minutes. Name two measures that let the survivors cope with a regional failover during those 6 minutes.
Show answer
Keep pre-provisioned headroom (a minimum fleet size that already covers the failover load, or a warm pool), and shed low-priority load while the scaler catches up. Gradual traffic shifting and client backoff with jitter also reduce the spike.