Did you know you can load-balance virtual machines (VMs) within Windows Azure?
The following content is a walk through of how to set up load-balancing across two VMs within Windows Azure.
- Windows Azure account is created
- Windows Server 2012 R2
- Internet Information Services
OK, let’s get started:
CREATING A VIRTUAL MACHINE WITHIN WINDOWS AZURE
Navigate to http://manage.windowsazure.com/ and either log into your account or sign up for a trial account.
Select NEW on the bottom left corner:
Select COMPUTE --> VIRTUAL MACHINE --> FROM GALLERY:
Select “Windows Server 2012 R2 Datacenter" from the list of offerings and move to step two by selecting the arrow on the bottom right:
Type in a virtual machine name, choose a size for your VM, type in a user name (used for the local admin account), add a password, and move to step three by selecting the arrow on the bottom right.
On step three I changed the name of the CLOUD SERVICE to something more generalized because it will be the DNS name used from the outside that will load balance across the two servers. Select a region to host the server and a storage group to store the data for the servers (.VHD files). I also elected to create an availability set because I want to eliminate single points of failure. Move to step four by selecting the arrow on the bottom right.
“An availability set is a group of virtual machines that are deployed across fault domains and update domains. An availability set makes sure that your application is not affected by single points of failure, like the network switch or the power unit of a rack of servers.”
The server will host a web site I going to open port 80 by selecting HTTP from the drop down list. However you may change the port number if desired. Complete the virtual machine creation process by selecting the check on the bottom right:
SETTING UP LOAD-BALANCING
Within the Windows Azure portal select VIRTUAL MACHINES and the select the VM you created:
From the navigation at the top select CONFIGURE:
Select the default stand-alone endpoint. Step two is where we’ll configure the load-balanced set.
Select a name such as HTTP or type in a new name, select the protocol, define a port, and finally check the CREATE A LOAD-BALANCED SET option. Move to step three by selecting the arrow on the bottom right.
Type in a name for the load-balanced set, select a probe protocol and port. Select the probe interval and well as the number of probes you’d like sent before the endpoint is considered unresponsive. Complete the virtual machine creation process by selecting the check on the bottom right.
A probe is used to determine if VMs have failed (software or hardware). If a failure is detected, failover to healthy VMs will occur.
ADDING VMs TO A LOAD-BALANCED SET
Repeat process above to create another virtual machine. Note: when creating the second virtual machine on step three select the CLOUD SERVER (and AVAILIBITY SET if you created one) that was created during the setup of the first virtual machine (e.g. “LBWEBSITE” & “FaultTolerant”) and leave the PROTOCOLS as default (we’ll add port 80 later).
Once the second VM is created Within the Windows Azure portal select VIRTUAL MACHINES and the select the second VM created. Select ENDPOINTS and on the bottom of the page select ADD:
On the ADD ENDPOINT dialog select ADD AN ENDPOINT TO AN EXISTING LOAD-BALANCED SET and choose the name of the load-balanced set created in the previous steps. Once completed select the arrow on the bottom right to proceed to step two.
Type in a name and select the check mark on the bottom right to complete adding a VM to a load-balanced set.
CONFIGURE INTERNET INFORMATION SERVICES (IIS)
I logged onto both servers and added IIS from the Add Roles and Features wizard:
Once IIS was installed on both server I added some text to the default iisstart.htm page to show which server is serving up content.
VIEWING LOAD-BALANCED RESULTS
In a previous step I specified the name of the public DNS name (LBSETNAME I named mine CBIIS-LB). In the Windows Azure portal select CLOUD SERVICES and select the name of the cloud service defined in previous step (e.g. LBWEBSITE). Select the name of the cloud service without navigating into the dashboard. Under the column named URL you’ll see the name of the load-balanced name followed by .cloudapp.net. In my case it will be http://CBIIS-LB.cloudapp.net.
Select the URL and select “ctrl + f5” until you see all load-balanced servers render content. Mine show the VM name in the upper left of the page:
VIDEO (start at 20 sec and look at how the VM names change in the upper left hand corner)
Congratulations! You’ve load-balanced two Window Server 2012 R2 IIS servers using Windows Azure VMs and Load-Balancing Sets.
ADDITIONAL WINDOWS AZURE LOAD BALANCING OPTIONS
WINDOWS AZURE TRAFFIC MANAGER: http://www.windowsazure.com/en-us/services/traffic-manager/ & http://msdn.microsoft.com/library/windowsazure/hh744833.aspx
ACCESS CONTROL LISTS (ACLs): http://msdn.microsoft.com/en-us/library/windowsazure/dn376541.aspx