Phit

Azure Availability Sets vs. Placement Groups

· 7 min read · Exercise How-To

In this article
  1. Background: The Need for High Availability
  2. How Availability Sets Work
  3. How Placement Groups Work
  4. How to Choose: Availability Sets vs. Placement Groups
  5. Common Problems and Troubleshooting
  6. Cost Comparison
  7. Safety and Limitations
  8. Frequently Asked Questions

Azure availability sets and placement groups are both features designed to improve the resilience and availability of your Azure virtual machines (VMs), but they operate at different levels and serve distinct purposes. Availability sets focus on distributing VMs across fault domains and update domains within a data center, while placement groups provide guarantees about the physical proximity of VMs to each other, often for low-latency scenarios.

Background: The Need for High Availability

Cloud computing promises scalability and resilience, but single points of failure can undermine these benefits. A single data center, or even a single rack within a data center, can experience outages due to power failures, network issues, or hardware malfunctions. To mitigate this, Azure offers various tools to distribute workloads and protect against these failures. Availability sets and placement groups are two key components of this strategy, each addressing different aspects of resilience and performance.

How Availability Sets Work

An availability set is a logical grouping of virtual machines that Azure manages as a unit. The core principle is that Azure distributes VMs within an availability set across multiple fault domains and update domains within a data center.

  • Fault Domains: Represent an isolated hardware failure domain. A fault domain is a group of servers that share a common power source and network switch. Distributing VMs across fault domains ensures that a failure affecting one fault domain doesn't impact all VMs in your set.
  • Update Domains: Represent a group of VMs that will be restarted together during planned maintenance events, like patching or operating system updates. Azure ensures that VMs in different update domains are restarted at different times, minimizing the impact of maintenance on your application’s availability.

When you create an availability set, you specify the number of VMs you want to include. Azure then automatically distributes these VMs across the available fault domains and update domains within the chosen Azure region. The number of fault domains and update domains varies by region; Azure automatically handles the distribution, but you can specify a minimum number of fault domains for increased resilience. For example, you might create an availability set with three VMs. Azure will place one VM in each of three fault domains, and these VMs will be updated in three separate update domains. This means if one fault domain fails, only one VM goes down. And if Azure needs to update the operating system, only one VM is updated at a time, keeping at least two VMs online.

Important Note: Availability sets do not protect against all types of failures. They protect against hardware failures within a data center. They don't protect against region-wide outages or software bugs.

How Placement Groups Work

Placement groups are a more recent addition to Azure and provide stronger guarantees about the physical proximity of VMs. They are designed to optimize network latency and throughput for applications that require very low latency communication between VMs, such as high-performance computing (HPC), distributed databases, and machine learning clusters. There are three types of placement groups:

  • Proximity Placement Group (PPG): Guarantees that the VMs within the group are located within the same Azure region, and as close as possible to each other. This reduces network latency.
  • Fault Domain Placement Group (FDPG): Builds on availability sets, providing more control over fault domain placement and guaranteeing that VMs are distributed across a specific number of fault domains. This is useful when you need finer-grained control over fault tolerance.
  • Zone Placement Group (ZPG): Guarantees that VMs are distributed across multiple Azure availability zones within a region. Availability zones are physically separate locations within an Azure region, each with independent power, networking, and cooling. ZPGs provide the highest level of availability and fault tolerance.

Unlike availability sets, placement groups don't automatically handle fault domain and update domain distribution. They provide the placement guarantees; you still need to use availability sets in conjunction with placement groups to achieve both proximity and resilience. For instance, you might create a proximity placement group and then deploy VMs within that group that are also part of an availability set. This ensures low latency and distributes the VMs across fault domains.

How to Choose: Availability Sets vs. Placement Groups

The choice between availability sets and placement groups depends on your application’s requirements:

  • Use Availability Sets when: Your primary concern is protecting against hardware failures within a data center and maintaining application availability during planned maintenance. You want a simple and cost-effective solution for basic high availability.
  • Use Placement Groups when: You need to minimize network latency between VMs. Your application requires very low latency communication, such as HPC, distributed databases, or machine learning workloads. You need more granular control over fault domain placement (FDPG). You need to distribute VMs across multiple availability zones (ZPG) for maximum availability.
  • Use Both: For optimal results, combine availability sets and placement groups. Use placement groups to ensure proximity and performance, and use availability sets to ensure fault tolerance within that proximity.

Consider the following factors:

  • Latency Requirements: If latency is critical, use placement groups.
  • Fault Tolerance Requirements: If fault tolerance is paramount, use availability sets or zone placement groups.
  • Cost: Availability sets are generally less expensive than placement groups.
  • Complexity: Availability sets are simpler to configure and manage.

Common Problems and Troubleshooting

Several issues can arise when working with availability sets and placement groups:

  • Insufficient Capacity: Azure may not have enough capacity in the chosen region to fulfill your request for an availability set or placement group. Try a different region or reduce the number of VMs.
  • Placement Group Restrictions: Certain VM sizes and operating systems may not be supported by all placement group types. Consult the Azure documentation for compatibility information.
  • Incorrect Configuration: Ensure that your VMs are properly assigned to the correct availability set or placement group. Use the Azure portal or Azure CLI to verify the configuration.
  • Maintenance Events: Be aware that maintenance events can still impact availability, even with availability sets. Plan for maintenance windows and consider using zone placement groups for increased resilience.

Cost Comparison

Generally, availability sets have no direct cost. You pay for the underlying virtual machines and storage. Placement groups, particularly Zone Placement Groups, often incur additional costs. Proximity Placement Groups are typically free but can have limitations on the number of VMs they can contain. Zone Placement Groups have a per-VM charge, so the cost increases with the number of VMs in the group. Always review the Azure pricing documentation for the most up-to-date cost information.

Safety and Limitations

While both availability sets and placement groups enhance resilience, they are not foolproof. They do not protect against:

  • Region-Wide Outages: If an entire Azure region experiences an outage, all VMs in your availability sets and placement groups will be affected.
  • Application-Level Failures: Availability sets and placement groups do not address application-level failures, such as software bugs or configuration errors.
  • Denial-of-Service Attacks: These features do not protect against denial-of-service attacks.

Always design your application with redundancy and fault tolerance in mind. Consider using multiple regions and implementing robust error handling and recovery mechanisms.

Frequently Asked Questions

What’s the difference between an availability set and a region?

An availability set is a grouping of VMs within a single Azure region. A region is a geographically distinct location containing multiple data centers. Availability sets help protect against failures within a region, while using multiple regions provides protection against region-wide outages.

Can I move a VM from one availability set to another?

Yes, you can move a VM between availability sets, but it involves stopping the VM, deallocating it, and then re-creating it in the new availability set. This will cause downtime, so plan accordingly.

Do I need to use both availability sets and placement groups?

Not necessarily. If your primary concern is high availability, an availability set may be sufficient. If you need low latency, a placement group is essential. For optimal results, use both to achieve both proximity and fault tolerance.

What happens if an entire fault domain fails?

If a fault domain fails, all VMs within that fault domain will become unavailable. However, because your VMs are distributed across multiple fault domains within an availability set, only a subset of your VMs will be affected, ensuring continued application availability.

Can I resize an availability set after it’s created?

Yes, you can increase the number of VMs in an availability set after it's created. However, decreasing the number of VMs may not be possible, depending on the configuration. It’s generally best practice to plan your availability set size upfront.