Regions and availability zones
Thursday, 14:20: one of Frankfurt's three data-centre zones loses power. Two-thirds of StayHub's servers are perfectly healthy, yet bookings stop for 47 minutes.
"The cloud" is real buildings in real places. Where yours are decides speed, what failures you survive, and which laws apply.
- Problem
A hotel booking platform must stay up when a data centre loses power, answer European guests fast, and keep EU guests' personal data where the law allows.
- Why the simple system fails
Everything in one data centre: one fire, flood or power fault takes the whole business down, and moving data later is a painful migration.
- Engineering concept
Clouds are split into regions (geography) made of availability zones (isolated data centres). Spread across zones for failures; choose regions for latency and law.
- Technology
Regions, availability zones, multi-AZ load balancers and databases, cross-region replication, DNS failover.
- Trade-offs
Each step of geographic spread buys resilience and latency at the price of cost, consistency and operational complexity.
The problem
2 min- Omar · On-call SREPower loss in zone eu-central-1a. App VMs in zones b and c: healthy. Bookings: zero. Logins failing.
- Karim · CTOWe just rebuilt across three zones. How is one zone taking us down?
- You · Engineer at StayHubWhere do the database and the session cache run?
The big idea
4 minMulti-AZ means every tier, especially the ones holding data.
The database was restored by hand into zone b: 47 minutes, about 800 bookings lost. With a synchronous standby in another zone, the same failure costs one to two minutes and no committed data.
How it works
5 min- 1Region
A is a geographic area (Frankfurt, Paris, Singapore) where a provider runs several data centres. Chosen for latency to users and for the law. Regions are far apart and independent.
- 2Availability zones
An availability zone is a separate data centre inside a region, with its own power and network, about 1–2 ms from its neighbours: close enough to wait for, far enough not to fail together.
- 3Multi-AZ: a standby that keeps up
: each write is stored on the primary and a standby in another zone before it's confirmed. If the zone dies, the standby is promoted in about 60–120 s.
- 4RPO and RTO
RPO is how much recent data you can lose; RTO how long you can be down. Multi-AZ zone failure: RPO ≈ 0, RTO ≈ 2 minutes.
- 5Multi-region: far, so async
survives losing a whole region. At 10–160 ms per round trip, replication must be asynchronous, accepting a few seconds of possible loss.
- 6Region choice is a legal choice
rules like decide which regions may hold EU guests' data. Backups and logs count.
Watch a decision being made
4 minYou make every tier survive a zone; Lina checks
A full Frankfurt zone failure must cost no committed bookings and at most a couple of minutes of errors.
- 1List every stateful piece
PostgreSQL (zone a only), Redis sessions (zone a only), object storage (regional), Kafka (managed, 3 zones).
Why: Outages hide in the pieces that hold data. Lina's check: confirm managed services' zone settings, don't assume.
- 2Give each a standby in another zone
PostgreSQL multi-AZ with a synchronous standby; Redis replica with automatic failover.
hclresource "aws_db_instance" "bookings" { multi_az = true } resource "aws_elasticache_replication_group" "sessions" { automatic_failover_enabled = true multi_az_enabled = true }Why: 1–2 ms per write buys RPO ≈ 0 for a zone failure.
- 3Size for losing a zone
9 app VMs, each zone sized for 50% of peak, so any two carry 100%.
Why: The survivors absorb the lost zone's traffic at the busiest hour.
- 4Write RPO/RTO down, then drill
Zone: RPO ≈ 0, RTO ≈ 2 min. Region: restore from Paris backups, hours. Force a failover every quarter and time it.
Why: Apps that cache connections or DNS can fail to follow the new primary; only a real failover shows it.
In real life
3 minSlack: zone-level isolation
- Has publicly described reworking its architecture so traffic can be drained from one availability zone
- A sick zone shouldn't hurt the rest of the region
- Big effort, within one region's latency
Fits when zone problems are the outages you actually see.
Netflix: region-level evacuation
- Has publicly described running in several AWS regions and practising moving all traffic out of one
- Survives a whole region failing
- Needs cross-region data and constant rehearsal
Fits a global product where a region outage is unacceptable.
What goes wrong
3 minWhen the database's zone fails, every app server is healthy and useless.
Multi-AZ on every stateful service, with a tested failover.
Losing a zone pushes the survivors past 100%.
Size so the remaining zones carry the peak.
Backups, logs and vendors quietly move data elsewhere.
DR copies in the same jurisdiction (Paris), and a data map.
Trade-offs
3 min| Setup | Survives | You pay |
|---|---|---|
| Single-AZ | A server crash (if ≥ 2) | A zone outage is a full outage |
| Multi-AZ | A data centre, in minutes | ~1.3–2× for data tiers |
| Multi-region active-passive | A region, after failover | Idle capacity; seconds of data loss |
| Multi-region active-active | A region, near-instantly | Write conflicts; heavy engineering |
- Karim · CTO47 minutes, 800 bookings. Let's run active-active in Frankfurt and Paris.
- Lina · Senior engineer, your mentorThursday was a zone failure. Multi-AZ fixes it for about €6,000 a month. Active-active is months: who owns a booking when both regions take writes?
- Karim · CTOAnd when the whole region goes down?
Your job as tech lead
4 minClaude Code can write the code for this. You still own the decisions, and you have to know what good looks like to accept or reject its work.
- Which failures StayHub must survive: a zone automatically; a region from Paris backups and a written plan.
- Which stateful pieces must be multi-AZ: bookings PostgreSQL and the session Redis.
- Where every copy of EU guest data may live: Frankfurt and Paris yes; Singapore no.
In our infrastructure code, switch the Frankfurt bookings PostgreSQL to multi-AZ with a synchronous standby in another zone, and the same for the Redis session store. Don't change instance sizes, Singapore or backup destinations. The app must connect by the provider's endpoint name, never an IP, and retry for up to two minutes during failover: show me today's client settings. Show the plan first, with the monthly cost increase and any restart. Then write a staging failover runbook with what to measure.
- Both the database and Redis get a standby in another zone; nothing else changes size or region.
- The app connects by endpoint name and retries: Claude shows the exact setting.
- In the staging failover, bookings fail for about 1–2 minutes, not 47.
- Synchronous replication to another region.
- EU backups or logs copied to Singapore or the US "for disaster recovery".
- "Highly available" because app servers span 3 zones while the database is in one.
Check yourself
2 minNext episode: Karim forwards a sales pitch from a second cloud provider promising 30% savings, and you have to decide what it would really take to move.
Mark it complete to update your skill map.
Go deeper (optional)You don't need this to understand the lesson. Open it when a project needs the details: Technical deep dive, Visual diagram, Analogy, Check your understanding, Practice ladder, Explain it yourself.
Technical deep dive
You make every tier survive a zone; Lina checks
Make sure a full zone failure in Frankfurt costs StayHub no committed bookings and at most a couple of minutes of errors.
- 1List every stateful piece
Bookings PostgreSQL (zone a only), Redis sessions (zone a only), object storage (regional, already multi-zone), Kafka (managed, 3 zones).
Why: Stateless servers are easy to spread; outages hide in the pieces that hold data. Lina's check: include managed services and confirm their zone settings, don't assume.
- 2Give each a standby in another zone
PostgreSQL: multi-AZ with a synchronous standby. Redis: a replica in zone b with automatic failover.
Why: Synchronous across zones costs 1–2 ms per write and means a zone failure loses nothing that was committed (RPO ≈ 0).
- 3Size for losing a zone
9 app VMs, 3 per zone, each zone sized for 50% of peak, so any two zones carry 100%.
Why: Surviving a zone means the remaining zones must absorb its traffic, at the busiest hour, without falling over.
- 4Write down RPO and RTO
Zone failure: RPO ≈ 0, RTO ≈ 2 minutes. Region loss: restore from Paris backups, RPO ≤ 5 minutes (log shipping), RTO a few hours.
Why: Numbers turn "we're resilient" into a promise you can check, and show the business what a region loss would still cost.
- 5Drill it
Every quarter, force a database failover in a quiet hour and time it end to end: errors, reconnects, alerts.
Why: Apps that cache connections or DNS can fail to follow the new primary. Only a real failover reveals that.
| Goal | Single-AZ | Multi-AZ | Multi-region (active-passive) | Multi-region (active-active) |
|---|---|---|---|---|
| Survives a server crash | If ≥ 2 servers | Yes | Yes | Yes |
| Survives losing a data centre | No | Yes, minutes | Yes | Yes |
| Survives losing a region | No | No | Yes, after failover | Yes, near-instant |
| Typical RPO in a disaster | Last backup | ~0 for a zone | Seconds (lag) | Seconds, plus conflicts |
| Relative cost | 1× | ~1.3–2× | ~1.5–2.5× | ~2–3× plus heavy engineering |
Visual diagram
A multi-AZ booking platform in an EU region, with an optional standby region for disaster recovery.
Analogy
- A bankA city where the bank operatesThe cloudA region
- A bankThree buildings, each with its own generatorThe cloudAvailability zones
- A bankLedgers copied in two buildingsThe cloudMulti-AZ
- A bankA second branch in another cityThe cloudMulti-region
- A bank"Records may not leave the country"The cloudData residency rules
Where the analogy breaks: a bank clerk can phone another city and wait. Software syncing across regions waits on every write, so most systems copy data across regions with a delay, and can lose the last few changes in a disaster.
Check your understanding
Practice ladder
Trace a zone loss at peak
Scenario Warm-upBefore your fix, StayHub's API ran 6 VMs, 2 per zone, at 70% CPU each during the evening peak. The database was already multi-AZ.
Zone c loses power at 20:00 (peak).
- What CPU load do the remaining VMs face?
- What happens over the next minutes if autoscaling takes 5 minutes to add VMs?
- How many VMs per zone would let two zones carry the peak at no more than about 70% CPU?
Fill in the recovery table
Design PracticeLina's table states what StayHub can lose (RPO) and how long it's down (RTO) in each failure, after your fixes. Fill in the blanks.
| Failure | Protection | RPO | RTO |
|---|---|---|---|
| One app VM crashes | 9 VMs, load balancer | 0 | seconds |
| Zone a loses power | Multi-AZ DB (sync), Redis replica, 3 zones sized at 50% | ___ | ___ |
Someone runs DELETE FROM bookings by mistake | Point-in-time recovery, 14 days | ___ | ___ |
| The whole Frankfurt region is unavailable | Backups + log shipping to Paris | ≤ 5 min | ___ |
Place StayHub for American guests
Design Practice20% of StayHub's guests are now in the US, and search feels slow there (Frankfurt ↔ US East ~90 ms per round trip, several round trips per page). Leadership wants: faster search in the US, no loss of committed bookings if a data centre fails, EU guests' personal data kept in the EU, and a team of 18 engineers.
Propose where each piece runs (search, hotel content, bookings, guest profiles, backups) and say what you'd not do yet.
Synchronous replication to Paris?
Decision StretchAfter the BergHotels questionnaire, Karim asks: "Can we promise zero data loss even if all of Frankfurt fails? Make the Paris copy synchronous."
Facts: Frankfurt ↔ Paris round trip ~10 ms. A checkout makes 5 sequential writes. At peak, about 1 checkout per second (~1,000 bookings an hour by day, more at sale peaks). Today Paris receives an async log stream, typically under 5 seconds behind.
Write a short decision: "We chose X over Y because…, accepting the risk of…".
Explain it yourself
Explain to a product manager the difference between multi-AZ and multi-region, and when you'd recommend each.