Availability Zones and Availability Sets

Watch the video to deepen your understanding.
SubscribeComplete the full lesson to earn 25 points
Work through each section, then tap “Mark as Complete” on the last one.
Lesson: Availability Zones and Availability Sets
In the world of cloud computing, "downtime" is the enemy of business continuity. Whether it is a hardware failure, a localized power outage, or a routine maintenance update, your infrastructure must be designed to withstand these events. This lesson explores two fundamental architectural concepts in cloud design: Availability Sets and Availability Zones.
1. Introduction: Why Availability Matters
Availability refers to the percentage of time a system is operational and accessible to users. High Availability (HA) ensures that your services remain online even when individual components fail.
To achieve HA, you must eliminate Single Points of Failure (SPOF). If your entire application runs on a single server, a hardware failure in the data center will take your application offline. By distributing your resources across different physical locations, you ensure that the failure of one component does not result in the total failure of your service.
2. Understanding Availability Sets
An Availability Set is a logical grouping capability that ensures the virtual machines (VMs) you place within it are isolated from each other when they are deployed within a cloud data center.
How it Works
Availability Sets rely on two concepts:
- Update Domains (UD): A group of VMs and underlying physical hardware that can be rebooted at the same time. During planned maintenance, the cloud provider ensures that only one UD is updated at a time.
- Fault Domains (FD): A group of VMs that share a common power source and network switch. By placing VMs in different FDs, you protect your application from hardware, network, or power failures.
Practical Example
Imagine you have a web application running on two VMs. If you put them in the same Availability Set, the cloud provider will automatically distribute them across different racks (Fault Domains). If a top-of-rack switch fails, only one VM goes down, while the other continues to serve traffic.
3. Understanding Availability Zones
An Availability Zone (AZ) is a high-availability offering that protects your applications and data from data center failures. An AZ is a physically separate location within an Azure/AWS/GCP region. Each zone is made up of one or more data centers equipped with independent power, cooling, and networking.
How it Works
Unlike Availability Sets, which protect against hardware failure within a single data center, Availability Zones protect against the failure of an entire data center facility. If an entire data center loses power or connectivity, your resources in other zones remain unaffected.
Comparison Table
| Feature | Availability Set | Availability Zone |
|---|---|---|
| Scope | Single Data Center | Multiple Data Centers (Region-wide) |
| Protects against | Hardware/Rack failure | Facility/Power/Network failure |
| Latency | Very low (same rack/row) | Low (within the same region) |
| Redundancy | Fault Domains/Update Domains | Physical isolation of facilities |
4. Implementation (Code Examples)
While configurations vary by provider, the logic remains consistent. Below is a conceptual example using Azure CLI to create an Availability Set.
Deploying to an Availability Set
# Create an Availability Set
az vm availability-set create \
--name myAvailabilitySet \
--resource-group myResourceGroup \
--platform-fault-domain-count 2 \
--platform-update-domain-count 5
Deploying to Availability Zones
When deploying to zones, you specify the zone parameter directly in the resource configuration:
# Deploying a VM to Availability Zone 1
az vm create \
--resource-group myResourceGroup \
--name myVM1 \
--image Ubuntu2204 \
--zone 1
Note: To achieve true high availability, you would deploy a second VM to
zone 2and place a Load Balancer in front of them to distribute traffic.
5. Best Practices and Common Pitfalls
Best Practices
- Use Load Balancers: Availability Sets and Zones provide the infrastructure for redundancy, but you need a Load Balancer to route traffic away from a failing instance.
- Stateless Design: Keep your application tier stateless. Store session data in a managed cache (like Redis) or a database, rather than locally on the VM. This allows any VM in your set or zone to handle any request.
- Automated Scaling: Combine HA designs with Auto-scaling groups to ensure that if a zone or set experiences a failure, the system automatically spins up new instances to maintain capacity.
- Health Probes: Always configure health probes on your Load Balancer. If a VM becomes unresponsive, the probe detects it and stops sending traffic to that specific instance.
Common Pitfalls
- Ignoring Latency: While Availability Zones are geographically close, there is a slight increase in latency compared to nodes in the same data center. Ensure your application architecture can tolerate millisecond-level latency differences.
- Misunderstanding Scope: A common mistake is assuming that Availability Sets protect against region-wide outages (e.g., a massive natural disaster). They do not. For protection against region-level failures, you must implement Region Replication (Disaster Recovery).
- Hardcoding IPs: Never hardcode the IP addresses of your VMs. Always use DNS names or Load Balancer front-end IPs, as the IP addresses of individual VMs will change if they are replaced during a failover.
6. Key Takeaways
- Redundancy is mandatory: If your application is critical, it must be distributed across multiple physical fault domains.
- Availability Sets protect against local hardware failures within a data center.
- Availability Zones protect against entire data center failures by utilizing physically separate facilities.
- Defense in Depth: Use Availability Zones for high availability, and combine this with cross-region backups for comprehensive disaster recovery.
- Load Balancing: High availability is only as effective as your ability to route traffic away from failed components. Always pair your availability strategy with a robust load-balancing solution.
Enjoying the courses?
Everything stays free. Pro shows fewer ads, doubles your daily points limit so you progress twice as fast, and lets you read each lesson on one page.
- ✓ Fewer advertisements
- ✓ 2× daily points limit
- ✓ Distraction-free lessons