Course contents

14. Cloud and Infrastructure Lesson 5 of 8

Regions and Availability Zones

Watch a zone outage take down servers that share a data centre, size capacity for N+1 zones, and see what failing over to a distant region costs.

15 minIntermediate8 steps
Loading the interactive simulation…
Loading the knowledge check…

Summary

  • A region is a geographic area with several isolated availability zones about a millisecond apart.
  • Copies in one zone share its power and network: spread instances across zones.
  • To survive losing one of N zones, each zone needs peak ÷ (N − 1) of capacity: three zones cost 50% headroom, two cost 100%.
  • Statically stable systems already run the capacity they need during an outage; they do not scale to recover.
  • Regions are tens to hundreds of milliseconds apart; failing over between them needs capacity and replicated data waiting there.
Deep diveHow it works, trade-offs, failure modes, misconceptions and the interview angle.

What it is

Cloud providers group their data centres into regions: geographic areas, usually around one metropolitan area, each offering the full set of services. Inside a region are several availability zones (AZs, typically three or more). A zone is one or more data centres with independent power, cooling and networking, physically separated from the other zones (kilometres to tens of kilometres) so that a fire, flood or power failure hits only one. Zones in a region are linked by high-bandwidth, low-latency private networks: a round trip between zones is typically on the order of a millisecond or two.

Regions are far apart, hundreds to thousands of kilometres, and are deliberately independent of each other: separate control planes, separate failure domains, often separate legal jurisdictions.

Why it exists

Hardware, buildings and power feeds fail. Redundancy only helps if the copies do not fail together, so providers expose the physical failure domains to you. Zones give you independent failure domains that are close enough to use as one system: you can spread servers across them, load-balance across them and replicate databases synchronously between them. Regions cover what zones cannot: a problem affecting a whole region (a faulty deployment of a regional service, a control-plane outage, a natural disaster), legal requirements to keep data in a country, and the plain fact that users on another continent are far away.

How it works

Multi-AZ. Stateless instances run in at least two, preferably three, zones behind a regional load balancer, which itself runs in every zone. Health checks eject instances in a failed zone. Managed databases offer a synchronous standby in another zone with automatic failover; distributed databases spread replicas across zones.

Sizing for a zone loss. If one of N zones fails, the other N − 1 must carry peak traffic. Each zone therefore needs peak ÷ (N − 1) of capacity, and the total is peak × N ÷ (N − 1): 200% of peak with two zones, 150% with three, about 133% with four. Three zones is the common sweet spot.

Static stability. During a zone outage everyone in the region tries to launch replacement capacity at once, and the control plane you would use for that may itself be degraded. A statically stable design does not need to change anything to survive: the capacity is already running and the load balancer only has to stop sending traffic to the failed zone.

Multi-region. A global routing layer (DNS-based traffic management, anycast front doors or global load balancers) sends users to a region. Two common shapes: active-passive, where a second region stands by and receives traffic only on failover, and active-active, where every region serves its nearby users all the time. Data crosses regions asynchronously in almost every design, because a synchronous round trip across an ocean would add its latency to every write.

Distance. Light in fibre covers roughly 200 km per millisecond, and real routes are longer than the straight line. A transatlantic round trip is roughly 70–100 ms, Europe to East Asia often 200 ms or more. Every sequential call between regions pays that in full.

When to use it

  • Multi-AZ: for anything in production that should survive a data-centre failure. It is cheap relative to the protection it buys and is the default for managed services.
  • Multi-region: when the business requires surviving a full regional outage with a short recovery time, when regulations require data to stay in specific places, or when you serve users on several continents and latency matters.

When not to

  • Single-zone deployments are acceptable for development, batch jobs that can rerun, and workloads where hours of downtime are tolerable.
  • Multi-region active-active is a poor default: it doubles infrastructure, forces you to decide how concurrent writes in different regions are reconciled, and multiplies operational complexity. Many systems are better served by multi-AZ plus a tested disaster-recovery plan.
  • Do not stretch a synchronous protocol (a two-phase commit, a synchronous replica, a chatty service call chain) across regions.

Trade-offs

Choice You gain You pay
Three zones instead of two Survive a zone loss with 50% headroom instead of 100% One more zone to deploy to; some services cost more
Pre-provisioned capacity (static stability) Survives outages without depending on scaling Idle capacity on normal days
Cross-zone traffic Independence from any one zone Inter-zone data transfer charges, about a millisecond per hop
Multi-region active-passive Survives a regional outage Standby cost, asynchronous replication (possible data loss), failover drills
Multi-region active-active Low latency worldwide, no cold standby Write conflicts or partitioned data ownership, highest cost and complexity

Alternatives

  • Single zone with backups: cheap, slow recovery (see disaster recovery).
  • Zonal deployments with cell-based architecture: independent copies of the whole stack per zone or per customer group, limiting the blast radius of bad deployments as well as hardware failures.
  • Edge platforms and CDNs: move static content and some computation close to users without running full regional stacks.

Failure modes

  • Hidden single-zone dependencies: a NAT gateway, a cache cluster or a primary database left in one zone undoes the spreading of everything else.
  • Survivors overload: spreading without headroom turns a zone loss into an overload of the remaining zones and possibly a cascading failure.
  • Gray failures: a zone that is degraded rather than down (packet loss, slow disks) may pass health checks while hurting latency; zonal shift tools and outlier detection help.
  • Failover without data: switching regions while the data layer is not replicated, or replicated with significant lag, either fails or loses recent writes.
  • Untested failover: DNS TTLs, client caches, capacity limits and forgotten configuration show up only when you actually fail over.

In production

Deploy every tier across at least two, preferably three zones and verify it: list the resources each zone depends on. Size for a zone loss and keep that headroom when autoscaling (scale on per-zone metrics, set minimums per zone). Keep traffic zone-local where you can to save cost and latency, but never depend on a single zone. Practise zone evacuation. For multi-region, document the RPO and RTO you need, replicate data continuously, keep the global routing TTLs low and run regular failover drills.

Common misconceptions

  • "More instances means more availability." Not if they share a failure domain.
  • "Autoscaling will replace the lost zone." Possibly slowly, possibly not at all while the region is stressed. Plan capacity that is already running.
  • "A region is one data centre." It is a set of independent zones; most outages affect one zone, not the region.
  • "Multi-region is always better." It is more resilient to a rare class of failure, at a large and permanent cost in money, latency of replication and complexity.

Interview angle

State the default without being asked: stateless tier across three zones behind a load balancer, database with a standby in another zone, capacity sized so two zones carry peak. Then discuss when you would go multi-region: an availability target beyond what one region offers, data-residency rules, or global users, and what it implies (asynchronous replication, conflict handling or data partitioning by home region, global routing, failover testing). Quantify: "Each zone runs half of peak, so 150% total."

Model assumptions

The simulation is a simplified model, not a benchmark. Each app server has 6 workers, a 60 ms mean service time (lognormal, cv 0.35) and room for 12 waiting requests, about 100 requests per second. Arrivals are random (Poisson). The regional load balancer is one node that stands for a managed balancer running in every zone; it probes every 500 ms (2 failures eject, 2 successes restore). A zone or region outage is every node in it failing at the same instant. The global traffic manager sends all traffic to Region EU while it is healthy (weights 1 : 0), probes every second and ejects after 2 failures. One-way latencies are fixed: users to Region EU 11 ms, to Region US 46 ms, 1 ms inside a region. Data replication is not modelled. Numbers show behaviour and orders of magnitude only.

The lesson as textEvery step of the simulation, written out.
  1. 1. Four servers, one data centre

    A cloud region is a geographic area (a metro area, roughly) with several availability zones (AZs). A zone is one or more data centres with its own power, cooling and network, a few to tens of kilometres from the other zones and connected to them by fast private links: a round trip between zones takes about a millisecond or two.

    Right now all four app servers run in Zone a. Users send 240 requests per second to the regional load balancer; each server handles about 100 per second, so they are about 60% busy and nothing fails.

    Scene: Users in Europe reach a regional load balancer that spreads 240 requests per second over four app servers, all in Zone a. Each is about 60% busy and every request succeeds.

    Key idea: A region is a set of independent zones close together. Putting everything in one zone ignores that independence.

  2. 2. Zone a goes dark

    One second in, Zone a loses power. Four servers fail at once: they were independent machines, but they shared a building, a power feed and a network.

    The balancer ejects them after two failed health checks, and then it has nowhere to send traffic: every request fails. Four servers gave no redundancy against this failure, because they all sat inside the same *failure domain*.

    Scene: One second in, all four servers in Zone a fail together. The load balancer ejects them within about a second and from then on every request fails because no backend is left.

    Key idea: Redundancy only counts if the copies do not share a failure domain. A zone is one.

  3. 3. Spread the servers over two zones

    Zone a is back. We move two of the servers to Zone b. Nothing else changes: the balancer still spreads 240 requests per second over four servers, each about 60% busy.

    Crossing zones costs little. The balancer runs in every zone, and a hop between zones adds about a millisecond, so latency stays where it was. Many providers do charge for traffic *between* zones, which is one reason not to make chatty calls across them needlessly.

    Scene: Two servers run in Zone a and two in Zone b behind the same regional load balancer. Each is about 60% busy and every request succeeds.

    Key idea: Spreading instances across zones turns a zone outage from “everything down” into “part of the capacity down”.

  4. 4. Zone b fails: the survivors are overloaded

    One second in, Zone b fails. This time the balancer still has two healthy servers in Zone a and sends everything there.

    But two servers can do about 200 requests per second and users send 240. Their queues fill and the excess is rejected, long after the health checks have done their job. Surviving a zone outage takes two things: copies in another zone *and* enough capacity there to carry the lost zone’s share.

    Scene: Zone b fails one second in. The load balancer moves all traffic to the two servers in Zone a, which become 100% busy with full queues; some requests keep failing with 503 after the failover.

    Key idea: If losing a zone overloads the rest, you have spread the risk without removing it.

  5. 5. Three zones, sized for one to fail

    Zone b is back and we add two servers in Zone c: six servers, two per zone, about 40% busy each.

    One second in, Zone c fails. Requests sent there fail for about a second until the balancer ejects them, then the four survivors carry all 240 requests per second, a bit over half busy each. No errors after the failover. To survive losing one of *N* zones, each zone needs peak ÷ (N − 1) of capacity: 100% extra with two zones, only 50% extra with three.

    The capacity was already running. That is *static stability*: the system needs no scaling, no new servers and no working control plane during the outage, which is exactly when those are least reliable.

    Scene: Six servers run two per zone. Zone c fails one second in; a few requests fail until it is ejected, then the four servers in Zones a and b carry all traffic, a bit over half busy, without errors.

    Key idea: N+1 zones: provision so that the remaining zones carry peak load without having to scale during the outage.

  6. 6. A second region, far away

    Zones protect against a data centre failing. They do not protect against a problem with the whole region: a bad deployment of a regional service, a control-plane outage, a natural disaster. For that you need a second region, hundreds or thousands of kilometres away.

    We put a global traffic manager in front and add three standby servers in Region US. It sends every request to Region EU and keeps US for failover. Distance is the cost: light in fibre covers about 200 km per millisecond and real routes are longer than straight lines, so from Europe the US region is about 90 ms away per round trip here, against about 20 ms to EU.

    Scene: A global traffic manager now sits in front. It sends all traffic to Region EU, where six servers in three zones serve it; Region US has three idle standby servers about 90 ms away round trip.

    Key idea: Zones are close enough for synchronous calls; regions are far enough apart that every round trip between them costs tens of milliseconds or more.

  7. 7. Region EU fails

    One second in, all of Region EU becomes unreachable. The traffic manager keeps sending requests there until two of its probes (one per second) fail, so users see errors for about two seconds. Then everything goes to Region US.

    Requests succeed again, but every one now crosses the ocean: median latency rises by about 70 ms, the extra round-trip distance. US had enough spare servers for the whole load, but only because someone paid for them in advance. And this model only moves the app tier: the data has to be in Region US already (replicated asynchronously, so the last moments of writes may be missing) or the failover is useless.

    Scene: Region EU fails one second in. Requests fail for about two seconds until the traffic manager ejects EU; afterwards Region US serves everything without errors, but median latency is about 70 ms higher.

    Key idea: Regional failover trades an outage for higher latency, and it only works if capacity and data are already waiting in the other region.

  8. 8. Zones for availability, regions for disasters and distance

    Region EU is healthy again and serves all traffic.

    The default for anything that must stay up is multi-AZ: stateless servers spread over three zones behind a zonal-redundant balancer, sized N+1 per zone, and a database with a synchronous standby in another zone. Calls between zones are fast enough to be synchronous.

    Multi-region is a bigger decision: it costs a second copy of everything, asynchronous data replication with its consistency questions, and regular failover drills. Choose it for disaster recovery, for data-residency rules, or to be close to users on other continents, not by default.

    Scene: Both regions are healthy. The global traffic manager sends all traffic to Region EU, where six servers in three zones are each about 40% busy; Region US stands by.

    Key idea: Multi-AZ is the baseline for high availability. Multi-region is a deliberate trade of cost and consistency for disaster tolerance and proximity.