In today's post titled Objective 2.5 - Manage ARM VM Availability, we will discuss things like how to configure Availability Sets for Azure Virtual Machines and load balance them. We will also briefly discuss fault and update domains.
The sub-objectives that we will be covering in this post are:
- Configure Multiple ARM VMs in an Availability Set of Redundancy.
- Configure each application tier into separate Availability Sets.
- Combine the Load Balancer with Availability Sets.
- Configure Fault Domains and Update Domains.
We have a lot to cover in this post, so let us start with our first sub-objective.
Configure Multiple ARM VMs in an Availability Set for Redundancy
Before we go configuring Availability Sets for Virtual Machines, let us first define what it is so that we understand the use case of them.
An Availability Set is a logical grouping capability that you can use in Azure to ensure that the VM resources you place within it are isolated from each other when they are deployed within an Azure datacenter.
Azure ensures that the VMs you place within an Availability Set run across multiple physical servers, compute racks, storage units, and network switches.
Microsoft recommends that you create an Availability Sets and group your VMs in it when you need redundancy for the applications.
This ensures that during either a planned or unplanned maintenance event, at least one virtual machine is available and meets the 99.95% Azure SLA.
The first step is to create an Availability Set so that we can place the VMs in it.
Import-Module AzureRM Login-AzureRmAccount New-AzureRmResourceGroup -Name MyResourceGroup -Location southindia New-AzureRmAvailabilitySet ` -Location southindia ` -Name FrontEndAvailabilitySet ` -ResourceGroupName MyResourceGroup ` -sku aligned ` -PlatformFaultDomainCount 2 ` -PlatformUpdateDomainCount 2
As you can see from the above code, we are first importing the Azure PowerShell module. Next step is to Login into Azure using the Login-AzureRmAccount cmdlet.
I am creating a new Resource group called MyResourceGroup so that I can place the availability set in it.
The final cmdlet is to create the Availability Set which takes the parameters of Resource group, location, Name, Update domains and fault domains.
Finally, we will be creating the Virtual Machines and adding them to the Availability Set at the time of creation.
Note: You can add a VM to an Availability Set after it is created.
You would be providing the details of the Availability Set in the Settings option of Blade Menu as seen below.
If you wish you know the steps to deploy the VM from the portal, head to my article for Getting started with Azure Virtual Machines.
I have created two VMs in the background and added it to the same Availability Set as seen below.
Also, notice that the two VMs are distributed across the 2 fault and update domains that we provided during the creation of the Availability Set.
We will discuss in depth about the Fault and Update domain further ahead.
Configure each application tier into separate Availability Sets
If you have Virtual Machines that are used similar workloads then Microsoft recommends that you put them in an Availability Set for each tier.
Let us look at an example below.
Let us assume that you would Web Servers and Application Servers, then the recommendation is to create two Availability Sets and place the Web Servers in one set and the App Servers in another.
By doing this, you guarantee that at least one virtual machine in each tier is available when there are maintenance activities performed by Microsoft.
I have written a handy PowerShell script that will list out the VM Name and the Availability Set it is part of.
$myResourceGroup = 'MyResourceGroup' $vms = Get-AzureRmVM -ResourceGroupName $myResourceGroup $result = foreach ($vm in $vms){ Get-AzureRmVM -Name $vm.Name -ResourceGroupName $myResourceGroup | select Name, @{Expression={$_.AvailabilitySetReference.Id.Split('/')[-1]};Label="AvailabilitySet"} } $result
The output will be similar to this.
Combine the Load Balancer with Availability Sets
Azure Load Balancer delivers high availability and network performance to your applications. It is a Layer 4 (TCP, UDP) load balancer that distributes incoming traffic among healthy instances of services defined in a load-balanced set.
There are two types of load balancers available in Azure, which are:
- External load balancer Used for exposing multiple VMs to the Internet in highly available manner.
- Internal load balancer Used for exposing multiple VMs to other VMs in the same VNET in a highly available manner.
If the load balancer is not configured to balance traffic across multiple virtual machines, then any planned maintenance event affects the only traffic-serving virtual machine, causing an outage to your application tier.
Placing multiple virtual machines of the same tier under the same load balancer and availability set enables traffic to be continuously served by at least one instance.
We will be discussing in depth about the load balancers in Virtual Network objectives.
Configure Fault Domains and Update Domains
When creating the Availability Set, we provided the number of Fault Domains and Update Domains as two each. I purposely did not spend time on what they do because we had this section to cover.
First, let us define what Fault and Update Domains are and remember that they are always associated with an Availability Set.
A Fault Domain (FD) is essentially a rack of servers. It consumes subsystems like network, power, cooling etc. So 2 VMs in the same availability set means Azure will provision them into 2 different racks so that if say, the network or the power failed, only one rack would be affected.
An Update Domain (UD) is used indicate groups of virtual machines and underlying physical hardware that can be rebooted at the same time.
Remember when using IaaS Virtual Machines, it is upto the tenant to patch the Virtual Machines, but sometimes Microsoft will have to patch the underlying hosts and by defining the Update Domains, you let Microsoft know how many VMs can be rebooted at once.
By default, there are 2 Fault Domains and 5 Update Domains configured when you try to create an Availability Set.
Update Domains can be increased to 20 at this time and Fault Domains can be increased to 3.
I hope this has been informative and thank you for reading!