Sub topic 5
Regions and Availability Zones
This chapter assumes you know what a server, an operating system, and an application are. It also assumes you are comfortable with basic networking terms such as IP address and HTTP. Earlier chapters showed that the cloud runs on pooled, virtualized hardware. That hardware sits in physical buildings, and where those buildings are affects speed, cost, legal compliance, and reliability.
Regions
A region is a geographic area where a provider operates a cluster of data centers. Examples on AWS are us-east-1 (N. Virginia) and eu-west-1 (Ireland). Regions are separate from each other. They have their own power, networking, and service endpoints, and most resources you create exist in one region only.
You choose a region based on four factors:
- Latency: Pick a region close to your users, because distance adds network delay.
- Data rules: Some laws and company policies require data to stay in a country or a bloc of countries.
- Service availability: Newer services and features may launch in some regions before others.
- Price: The same resource can cost different amounts in different regions.
Availability zones
An availability zone (AZ) is one or more data centers inside a region. Each AZ has independent power, cooling, and networking. AZs in a region are connected by fast, low-latency links, but they are far enough apart that a fire, flood, or power failure in one is unlikely to affect another.
The unit of failure matters here. A single server can fail, a whole AZ can fail, and in rare cases a region can have a problem. Spreading your workload across AZs protects you from the second case.
Seeing regions and zones in practice
The AWS CLI can list the zones in a region. This command shows the AZs available to your account in eu-west-1.
aws ec2 describe-availability-zones \
--region eu-west-1 \
--query "AvailabilityZones[].[ZoneName,State]" \
--output tableWhen you launch an IaaS virtual machine, you pick the region first and then, optionally, a zone. Many PaaS and SaaS offerings hide the zone choice and spread work across zones for you. That is one more layer the provider manages.
Common errors
- Running everything in one AZ. The workload is then down whenever that AZ has an outage. Place at least two instances in different AZs behind a load balancer.
- Assuming a region is the same as a zone. Multi-AZ protects against a data center failure. It does not protect against a whole-region problem. For that you need a second region, which costs more and adds complexity.
- Forgetting that data is region-bound. Copying data between regions is a deliberate step and usually costs money. Traffic between AZs in a region can also carry a small charge.
- Mixing up zone names across accounts. A name such as
eu-west-1amay map to different physical zones for different accounts. Use zone IDs, such aseuw1-az1, when you need to be sure two accounts refer to the same zone.
Exercise
Your web app runs on two virtual machines, both in eu-west-1a. Name the failure that would take it offline, and give one fix.
Show answer
An outage in availability zone eu-west-1a would take down both machines at once. The fix is to move one machine to a different zone, such as eu-west-1b, and put a load balancer in front of both so traffic goes to whichever is healthy.
Exercise
A company must keep customer data inside the European Union and wants low latency for users in Paris. Which choice, region or availability zone, addresses the data rule, and why?
Show answer
The region. Data location is decided by the region you create resources in, so you choose an EU region. Availability zones are all inside that one region, so they help with reliability, not with where the data lives.