Regions and Availability Zones
Learn how cloud providers split the world into regions and zones, and how to use them to balance speed, resilience, rules and cost.
Key takeaways
- A region is a geographic location for your resources, and you generally choose it explicitly.
- Zones within a region are designed to fail independently while staying close enough for fast communication.
- Spreading an application across zones protects against many common failures at modest extra effort.
- Using more than one region protects against larger events but adds real complexity around data.
- Resources don't automatically exist in several places; you or a managed service must arrange it.
A cloud region is a geographic area where a provider runs a group of data centers, and an availability zone is an isolated part of a region with its own power, cooling and networking. You choose a region mainly for distance to your users, legal requirements, available services and price. You use several zones so that one failure doesn't take your whole application down.
Names and exact definitions differ among providers, so confirm the details in your provider's documentation. The underlying ideas are consistent, and they shape almost every reliability decision in the cloud.
What a region is
When you create a server, database or storage container, you usually pick a region such as one on a particular country's coast or near a major city. The resource and its data live there unless you copy them elsewhere. Each region is largely independent: it has its own capacity, its own set of available services and often its own prices.
That independence is deliberate. A software fault or physical disaster in one region should not spread to another. Some provider functions, such as parts of account management or name services, work globally, and those shared pieces can occasionally affect many regions at once.
What a zone is
An availability zone is one or more data center buildings within a region, engineered so that it doesn't share critical dependencies with the other zones. Separate power feeds, separate cooling and diverse network paths mean that a fire, flood or electrical fault in one zone is unlikely to reach another.
Zones are connected by fast, high-capacity links. Because they're relatively close, the round-trip time between them is small, usually small enough that a database can write to two zones before confirming a change. Regions are much farther apart, so the same trick across regions adds noticeable delay.
Edge locations are a different thing. These are many smaller sites that cache content or handle connections close to users, without offering the full range of services. See edge locations and points of presence.
Choosing a region
Weigh these factors, roughly in this order for most projects.
- Legal and contractual requirements. Some data must stay in a certain country or economic area. This can rule out most options at once, and sovereign clouds and data residency covers why location alone may not be enough.
- Distance to users. Signals take time to travel, and that delay is set partly by physics. A region near most of your audience makes interactive pages feel quicker.
- Services and sizes available. New features and specialized hardware often appear in some regions long before others.
- Price. The same resource can cost different amounts in different regions.
- Closeness to your other systems. An application that talks constantly to a database or office system should sit near it.
Distance to your office isn't the right measure if your customers are elsewhere. You can test delay from a browser or with a command such as the following, using the address of a test resource in the candidate region.
curl -o /dev/null -s -w "connect: %{time_connect}s total: %{time_total}s\n" https://example.com/ On Windows PowerShell, use curl.exe instead of curl and NUL instead of /dev/null.
Using multiple zones
A typical resilient web application places at least two copies of the web or application tier in different zones, puts a load balancer in front of them and uses a database with a standby copy in another zone. If one zone fails, the load balancer stops sending traffic there and the database promotes its standby.
Two cautions apply. First, leave headroom. If each zone is already running near full, the survivor will buckle under the combined load. Second, new capacity may be harder to obtain during a large incident because many customers ask for it at the same moment, so running spare capacity in advance is more dependable than hoping to add it later.
Not every service is multi-zone by default. A single virtual machine and its attached disk typically live in one zone. Some managed services spread copies automatically, others only if you select that option and pay for it. Check each one.
Going multi-region
A second region guards against events that affect a whole region, including regional control-plane problems. When a cloud region fails explains how such outages spread.
Common designs, from cheapest to most demanding:
| Design | What runs in the second region | Recovery speed | Complexity |
|---|---|---|---|
| Backup and restore | Stored copies only | Slow | Low |
| Pilot light | Data replicated, minimal services ready | Moderate | Moderate |
| Warm standby | A smaller working copy | Fairly fast | High |
| Active in both | Full service taking traffic | Fastest | Very high |
Data is the hard part. Replication between distant regions is usually asynchronous, meaning the second copy lags slightly. If the first region disappears, the most recent writes may be lost. Letting both regions accept writes brings the problem of conflicting updates. Decide how much loss and downtime you can accept before picking a design; disaster recovery, RPO and RTO gives you the vocabulary.
State is what makes it hard
Spreading identical web servers across zones is straightforward because any copy can answer any request. The trouble comes from state, meaning information that has to be remembered between requests: database records, uploaded files, login sessions and queued jobs.
Move that state out of individual servers. Keep sessions in a shared database or cache, or in signed cookies. Put uploads in a storage service designed to span zones. Use a managed database option that maintains a standby in another zone, and make sure your application reconnects cleanly after a failover, since existing connections will drop. Programs that look up the database address once and cache it indefinitely may keep calling the failed machine.
Many clustered systems also need a majority of members to agree before they accept changes. With three members placed in three zones, losing any one zone still leaves two, which is a majority. With two members in one zone and one in another, losing the wrong zone stops the system. This arithmetic is why you often see designs built around three zones instead of two.
Background work deserves a thought too. A scheduled job that runs on one particular server disappears with that server's zone. Run it through a scheduler that can start it anywhere, and write it so that running twice does no harm.
Testing that it works
A design you haven't exercised is a hypothesis. Pick a quiet period, tell the people who need to know, and remove one zone's worth of capacity from service in a controlled way. Watch error rates, response times and how long recovery takes. Note anything that required a person to step in.
Start in a test environment and keep a clear way to undo the experiment. Teams that make this routine are practicing a light form of chaos engineering, and they tend to find configuration drift long before a real failure does. Also confirm that alerts arrive somewhere that doesn't depend on the zone or region you disabled.
Cost and billing effects
Extra copies cost extra: more servers, more database instances and more storage. Traffic between zones is often charged, and traffic between regions usually costs more. A chatty application that places its web servers in one zone and its cache in another can pay for every exchange. Look for the transfer lines on your bill after changing a layout.
Common mistakes
- Assuming "the cloud" replicates everything for you.
- Keeping backups only in the same region and account as the original data.
- Spreading servers across zones while leaving one shared component, such as a single file server, in one zone.
- Writing a recovery plan that depends on tools hosted in the region that failed.
- Never testing failover, then discovering an expired credential or missing setting during a real incident.
- Trusting zone labels to mean the same physical site in every account; with some providers the letter mapping differs per customer.
How much do you need?
A personal blog can live in one region with good backups stored separately. A business application that loses money every hour of downtime should span zones. A service with strict continuity obligations, or one whose customers span continents, may justify multiple regions.
Match spending to consequences. Estimate what an hour and a day of outage would cost, including reputation, and compare that with the monthly price and engineering time of each step up. Our overview of high availability and failover shows how to find the single points of failure that matter most.
Common questions
Does a nearer region always mean a faster site?
It helps with delay, but page weight, database queries and caching often matter more. A content delivery network can serve static files from near each visitor regardless of your region.
Can I move to another region later?
Yes, though it is a migration rather than a setting. You copy data, recreate resources and update addresses. Infrastructure defined as code makes this far easier.
Do two zones double my availability?
They improve it considerably for failures that stay within one zone. They don't help with bad deployments, deleted data or faults that affect the whole region.