Spread across zones and regions
A data-centre outage takes everything down.
Say it like this
A zone failure should be invisible and a region failure should be a controlled failover, so every tier runs in at least two zones behind the balancer, data replicates to a second region, and DNS health checks move traffic there when the primary region goes dark.
Basic solution
Run in at least two availability zones; for region loss, replicate data and fail over DNS to a second region.
Three zones in region 1, warm standby in region 2
Inside a region, zones fail over automatically. Across regions, async replication keeps a warm standby that DNS health checks promote when the primary region fails.
How it works
- Within a region, run every stateless tier (API servers, workers) in at least two availability zones, behind a load balancer that knows which zone each instance is in. If a zone fails, the balancer stops sending to it and the service keeps running on the remaining zones with less capacity.
- For stateful tiers, keep the primary in one zone and replicas in the others, with automatic failover inside the region (see replication-failover). A zone loss then costs seconds of failover, not data.
- Size each zone so the remaining zones can carry full peak load when one zone is lost: with two zones each must carry 100% of peak, so you run 2× capacity; with three zones each must carry 50%, so you run 1.5×.
- Replicate data continuously to a second region: database log shipping, cross-region object-store replication. Because it is asynchronous, measure the lag, since that lag is what you lose if the primary region dies.
- Deploy the services in the second region either warm (deployed but scaled down and idle) or active (serving its own share of traffic).
- Put health-checked DNS or anycast in front of both regions. When the primary region stops answering health checks, DNS routes new traffic to the second region, and the replica database there is promoted to primary.
- Drill the region failover on a schedule, including failing back, so that every secret, DNS record and runbook step is known to work.
What a zone is and is not
- Zones share a region's network and control plane but have separate power and cooling. A regional control-plane outage can still take all zones, which is why region failover exists.
Worked example
Video streaming platform, metadata and playback API
- 50M daily viewers, 10K API req/s at peak, metadata in Postgres (3 TB), segments in object storage (1.5 EB total, served by CDN).
- Three zones in the primary region, API fleet of 60 instances (20 per zone) sized so 40 instances carry peak. Zone loss: 20 instances gone, 40 remain, no user impact. Cost of headroom: 50% more compute than strictly needed.
- Postgres primary in zone A with a synchronous replica in zone B and an async replica in zone C. Zone A loss: automatic failover to B in about 30 s, no data loss.
- Second region, warm: object storage replicated continuously (lag about 15 minutes for new uploads), Postgres async replica (lag 1 to 2 s), API fleet deployed at 10 instances and scalable to 60 in 5 minutes.
- Region loss: DNS health checks fail after 90 s, traffic shifts to region 2, the replica is promoted losing about 2 s of metadata writes (progress updates, mostly harmless). Playback of existing videos keeps working through the CDN throughout; uploads from the last 15 minutes must be retried. Recovery time about 5 minutes, recovery point about 2 s.
- Cost: roughly 15% extra for the warm region, versus 100% for active-active.
Variants and when each wins
Multi-zone only
- Every tier spans several zones in one region and nothing exists elsewhere. It wins as the default, because it handles the common failures (host, rack, zone) at modest cost, though it does not survive a regional outage, which happens a few times a year across the big clouds.
Active-passive regions (warm standby)
- Data replicates to a second region where services are deployed but small. It wins when a region outage must be survivable but is rare, because failover takes minutes and loses only the replication lag.
Active-active regions
- Both regions serve traffic and users are routed to the nearest. It wins when latency and instant failover both matter, at the cost of partitioning writes by region or resolving conflicts, which is the hard part.
Cell-based within a region
- The stack is split into independent slices, each serving a subset of customers. It wins for limiting the blast radius of a bad deploy or a poison customer, without the cross-region data problem.
Recommendation: three zones always; active-passive region failover once the business cost of a region outage exceeds the standby cost; active-active only with data that partitions cleanly by region.
Failure modes
Not enough headroom
- A zone goes down and the remaining instances are overloaded, so the zone failure turns into a full outage. It happens because capacity was sized for peak with every zone healthy. Size for peak with one zone lost, and prove it by evacuating a zone in a test.
Hidden single-zone dependency
- The application spans three zones, but a NAT gateway, a bastion host or a Redis node lives in only one, and that zone fails. It happens because the inventory had gaps. Map every component's zone, including managed services, and alert on any resource that exists in one zone only.
Failover never drilled
- The region failover takes four hours because a secret, a DNS record or a runbook step was wrong. It happens because the procedure was written but never run. Drill it quarterly with real traffic, fail back afterwards, and time it.
Replication lag at failover
- The second region is missing 20 minutes of writes when it is promoted. It happens because cross-region lag grew and nobody was watching. Alert on the lag, and know the recovery point objective before promoting rather than discovering it afterwards.
Failback corrupts data
- After the primary region returns, both regions accept writes and the data diverges. It happens because the old primary database was simply switched back on without being fenced. Rejoin the old primary as a replica only, through a scripted procedure, never by turning it on.
Cross-zone data transfer costs
- The cloud bill doubles. It happens because traffic crosses zone boundaries on every request, and providers charge for cross-zone bytes. Route the hot path within a zone where possible, and keep cross-zone traffic for replication and failover.
Interviewer follow-ups
Answer out loud before you open each one.
How do you size a region for zone loss?
Compute peak capacity, then divide by the number of zones minus one. With three zones each must carry half of peak, so the fleet runs at about 67% utilisation. With two zones each must carry all of it. Three zones is the sweet spot between headroom cost and failure isolation.
What are recovery time and recovery point objectives, and who sets them?
RTO is how long the service may be down; RPO is how much recent data may be lost. The business sets them per data type: progress markers can lose seconds, payments cannot lose anything. The architecture follows: async replication for the first, synchronous or quorum for the second.
Why is active-active so much harder?
Both regions accept writes, so the same row can change in two places during the replication lag. You either partition writes by region (users homed in one region, no cross-region writes), use data types that merge (counters, sets), or accept last-writer-wins and the anomalies it brings. Each of those is a product decision, not just an infrastructure one.
How does the CDN change the picture for video?
Playback of existing content is served from edge caches that do not depend on either region, so a region failure affects only uploads, metadata writes and cache misses. That is why the metadata tier gets the failover investment and the segment tier gets replication plus long CDN TTLs.
Connections
The same parts on other clouds
The diagrams above name AWS services as one concrete example. Every part has a close equivalent elsewhere. In an interview, name the role first, such as “a managed Redis cache”, then the product you would pick.
| AWS | Used here as | Google Cloud | Microsoft Azure | Open source and others |
|---|---|---|---|---|
| Amazon Route 53 | DNS health checks | Cloud DNS | Azure DNS, Traffic Manager | Cloudflare DNS, NS1 |
| Application Load Balancer | Region 1 balancer | Cloud Load Balancing | Application Gateway, Azure Load Balancer | NGINX, HAProxy, Envoy |
| Amazon EC2 Auto Scaling | Zones A, B, C, Region 2 balancer + API | Compute Engine managed instance groups | Virtual Machine Scale Sets | Kubernetes Deployment with a HorizontalPodAutoscaler, Nomad |
| Amazon Aurora | Postgres primary, Postgres replica | AlloyDB for PostgreSQL, Cloud SQL | Azure Database for PostgreSQL or MySQL | PostgreSQL, MySQL, CockroachDB |
| Amazon CloudFront | CDN | Cloud CDN, Media CDN | Azure Front Door | Cloudflare, Fastly, Akamai |