This is Part 8 of Azure tutorial. In this video, we'll understand azure availability sets with a
simple example. Before that, let's understand fault domains and update domains. First, fault
domains. What does an azure data center contain? Well, in simple terms, it contains several racks
of servers. Each rack in turn may contain several servers with its own power supply and
network switch. In reality though, server racks are much more complicated than this. They may be
equipped with redundant power supplies and network switches. However, to keep this example simple,
let's just say a rack contains 15 to 20 physical servers with its own power supply
and network switch. So, you can think each rack of servers as a separate fault domain. For example,
if the power supply or network switch fails in a given rack, only the servers in that rack fails.
The rest of the server racks are isolated and unaffected. So, you may think of a fault
domain as a group of resources that may fail at the same time due to the same root cause.
It has a single point of failure. For example, if the power supply fails, all the servers in that
rack fails. It's very important we understand the concept of fault domains, because, if we deploy
our azure resources like virtual machines for example, in two or more fault domains, they
remain available should a failure occur in one of the fault domains. Now, Update Domain. The server
hardware and any supporting infrastructure in a data center is divided into multiple fault domains
and update domains. An update domain is a group of resources that can be updated and rebooted
if required at the same time. From time to time, patches and software updates need to be applied.
Some updates require servers to be rebooted. Only one update domain is rebooted at a time.
A rebooted update domain is then given another 30 minutes to recover before maintenance is initiated
on a different update domain. This obviously reduces the downtime to a great extent. So,
if you want your azure resources like virtual machines for example to be available
even during the update process, have them deployed across multiple update domains. Now, what is
an availability set? An availability set is a logical grouping for isolating virtual machine
resources from each other. Azure makes sure that the VMs we place in an availability set
run across multiple physical servers, computer racks, storage units and network switches. So,
if a hardware or a software failure happens, only a subset of our VMs are impacted and our overall
solution still stays operational. Availability sets are essential for building reliable cloud
solutions. Let's say, we have a simple two-tier web application. On one of the virtual machines,
we have a web server and on another virtual machine we have our database server. Now, to be
able to handle and process more requests, we have two web servers and two database servers. In real
world web applications that have lot of demand, for example google.com, gmail.com and amazon.com
may have many many web servers and database servers. However, to keep our example simple,
let's just stick to two web servers and two database servers. The load balancer obviously
distributes the incoming traffic between the two web servers. Now, let's understand what may happen
if we're not making use of availability sets. Well, all the four VMs, i.e the two web servers
and two database servers may end up in the same fault domain or update domain. As a result,
if there is a software failure or hardware failure like power supply or network switch failure,
all your web and database servers go down. End result, your web application is no longer
available. If it's an e-commerce application like amazon.com for example, just imagine
the extent of loss to the business, every second the system is down. So, if you are deploying two
or more virtual machines, always use availability sets for high availability. Since, in our example,
we have two tiers - a web tier and a database tier, we create two availability sets. One
for the web tier and the other, for database tier. Let's quickly look at this in action.
We are in the azure portal on "All Services" page. We want to create an availability set.
So, let's search for "availability sets" and then click "Create". Subscription - Free Trial
and then resource group. At the moment, we have two resource groups, but for this example,
let's create a new resource group "rg" for resource group and let's call it "test".
This new resource group will be automatically created, when this availability set is created.
Next, the name. It's a common convention to use the prefix "avail" for availability sets. In this
example, we're creating an availability set for our website. So, I'm going to name it "avail-web".
Next, the region where we want our azure resources to be deployed. At the moment, South India region
is selected and notice the message that we have here. Default domain count for this selected
location is two. This means, only we can have a maximum of two fault domains in the South India
azure region. Now, let's select a different region. Maybe, East US for example. Notice,
fault domains for this region defaulted to 2, but we can increase it up to 3. What does this mean?
Well, since we have set the fault domains count to 3 and when we create three virtual machines
each of them will be placed in three separate fault domains. If there is a fault like a power
failure for example, only one of the server racks is affected. This means,
only one of our VM is down, but the other two VMs from the other two fault domains are still
available. This in turn means, our workload, that is in this case, our web application
is still available to end users . Now, what do you think happens, if we create a fourth VM with just
these three fault domains. Well, it will be placed in one of the three fault domains. This means,
in one of the three fault domains, you will have two VMs and the rest two will have one each. Next,
Update Domains - Same idea like fault domains, the number of update domains you want. Let's say,
you have three VMs deployed across three update domains, if an update is installed and a restart
is required, only one update domain is restarted at any given time. This means, you have the other
two VMs available from the rest of the two update domains. Notice, update domains defaulted to 5,
but we can increase it up to 20 if we want to. let's review and create this availability set.
So, we just created our availability set avail-web. As you can see, our website contains
two web servers. So, let's place both these web servers in this availability set "avail-web". At
the moment, we are on "Create a virtual machine" screen in azure portal. In the interest of time,
I have filled in some of the details that are required for our VM creation. So subscription
is Free trial, resource group is our test resource group, that we just created. Virtual machine name,
I named it vm-web01. This is our first web server in the web tier and we are deploying
this to East US region and here is the important bit, Availability options. When I drop this down,
we have two options here- Availability zone and Availability set. We'll discuss the differences
between these two in our next video. For now, let's select "availability set" and then in the
drop down list here, we see our availability set, which we just created "avail-web". Let's select
that and then, I'm going to leave the rest of the defaults here and then review and create.
Our first web server deployment is in progress. While this is happening,
let's create our second web server. So, let's go back to "All Services", "Virtual Machine", Create.
In the interest of time, I've already filled, all the required details.
Resource group is our test resource group and I named this virtual machine vm-web02. Remember,
this is our second web server and we are deploying it to East US region and availability set,
we have selected the same availability set "avail-web", the same as our first web server.
I'm going to leave the rest of the values with their defaults and then, let's review and create.
There we go, our second web server deployment is also complete. Now,
let's go to "All Services" and then search for "availability sets".
If we go to our availability set, notice, both of our web servers are assigned different fault
domains and update domains If there is a problem, in one of the fault domains or update domains,
only one of our web servers will be down, we still have the other web server up and running. Even,
with our database servers, we can do the same thing, create a separate availability set,
maybe name it "avail-database" and place, both of our database servers in this availability set.
So, they get their own fault domains and update domains. If there is a problem in one of the
fault domains or update domains, only one of the database servers is down, we still have the other
database server up and running. Now, here is the important bit. For all virtual machines,
that have two or more instances deployed in the same availability set, Microsoft guarantees,
you will have virtual machine connectivity to at least one instance at least 99.95% of the
time. Before we conclude, one important point you have to keep in mind is, you can't add an
existing virtual machine to an availability set, after it is created. So, if you want a virtual
machine in an availability set, it's a decision you have to make at the time of creation not
after it is created. Let's quickly look at this in action. Let's go to virtual machines view page
Let's go to this last virtual machine. We created this virtual machine without an
availability set. Now, notice, when I click on this option "Availability and scaling", you have
a message here "The availability set can only be configured when creating a virtual machine", so,
it's basically saying we have to recreate the virtual machine if we want to move this virtual
machine in or out of an availability set. In our next video, we'll discuss the difference
between availability sets and availability zones. That's it in this video. Thank you for listening.