How to create a zone redundant load balancer?

photo of woman writing on tablet computer while using laptop
Reading Time: 4 minutes

Introduction

Zone Redundant Load Balancers are used in availability zone scenarios where we require that the application is not affected in response due to a zone failure. You may usually find 3 Availability zones in a region.

As shown in the diagram, we will use the following setup to configure our Zone redundant load balancer.

Zone Redundant Load Balancer Architecture

Step 1: Creating a Virtual Network

First, we create a resource group named ‘rg-loadbalancing‘ for our setup. And then, this will be used as a common group in every resource made.

rg-loadbalancing

Second, we create a Virtual Network with the following configuration:

  • Name: myVnet
  • region: East US
  • Address: 10.0.0.0/16
  • subscription: Azure subscription 1
  • resource group: rg-loadbalancing
  • subnet name: mySubnet
  • Subnet Address range: 10.0.0.0/24

And now, review and create.

myVnet

Step 2: Create a Network Security Group (NSG)

We will create a common NSG. And then, we will use them for every Virtual Machine created. And now, we will create the NSG with the following configurations.

  • Name: myNSG
  • region: East US
  • Address: 10.0.0.0/16
  • subscription: Azure subscription 1
  • resource group: rg-loadbalancing

After that, review and create. And then, we will add the following inbound rule in it.

  • AllowTagHTTPInbound
    • Source: Service Tag
    • Source service tag: Internet
    • Destination: Any
    • Service: HTTP
    • Action: Allow
    • Priority: 100
  • AllowTagRDPInbound
    • Source: Service Tag
    • Source service tag: Internet
    • Destination: Any
    • Service: RDP
    • Action: Allow
    • Priority: 200
Inbound rules NSG

Step 3: Create the 3 Virtual Machines

Create 3 VMs in three different zones and the rest configurations remain the same.

  • Name: VM-1 / VM-2 / VM-3
  • subscription: Azure subscription 1
  • resource group: rg-loadbalancing
  • region: East US
  • Availability options: Availability zone
  • Availability zone: Zone 1 / Zone 2 / Zone 3
  • Image: Windows Server 2016 Datacenter ( windows servers are good for practice)
  • size: Standard_B2s
  • Username: azureuser
  • Password: yourown
  • Confirm Password: yourown
  • inbound ports: HTTP, HTTPS, RDP
  • OS disk type: Standard SSD
  • Virtual network: myVnet
  • subnet: mySubnet
  • NIC network security group: Advanced
  • Configure network security group: myNSG
  • Boot diagnostics: Off ( to stop creating a storage account)

And now, verify and create each VM one by one.

Virtual Machines

Step 4: Create a Zone-Redundant Load Balancer

Now we will create a load balancer with the following configurations.

  • name: myloadbalancer
  • type: Public
  • SKU: Standard
  • virtual network: myVnet
  • subnet: mysubnet
  • resource group: rg-loadbalancing
  • location: East US
  • tier: Regional
  • Backend pool
    • Name: backendpoolzone
    • Virtual network myVnet
    • Backend Pool Configuration: NIC
    • IP configuration: Add
      • VM-1
      • VM-2
      • Vm-3
  • Loadbalancing rule
    • Name: lbrule
    • IP version: IPv4
    • Frontend IP address: loadbalancerip
    • Backend pool: backendpoolzone
    • Protocol: TCP
    • Port: 80
    • Backend Port: 80
    • health probe (create new)
      • Name: mylbProbe
      • protocol: HTTP
      • Interval: 5 seconds
      • Path: /
      • Port: 80
    • session persistence: None (as the rest option will keep routed to a particular VM)
    • ideal time out 4 minute
    • TCP reset: disabled
    • Floating IP: disabled
    • Outbound source network address translation (SNAT): use default outbound access.
  • FontendIP configuration:
    • Name: loadbalancerip
    • IP version: IPv4
    • IP type: IP address
    • Public IP address: Create new
      • Name: loadip
      • Availability zone: Zone-redundant
      • Routing preference: Internet

And then, we review and create the load balancer.

load balancing rule
frontend IP configurations

Step 5: Webserver installation on VMs

Download the RDP file of vm1 and vm2. We are using Remina Connect to run the virtual machines locally with an RDP connection. You can use Remote Desktop Connection in Windows. Install the IIS web server on vm1 and vm2 using server manager. And set up the default pages in a way that distinguishes both pages like we have done.

virtual machine 1 setup
virtual machine 2 setup
virtual Machine 3 setup

Step 6: Testing the zone-redundant load balancer setup

Copy the Public IP of the load balancer from the overview or frontend IP configuration. Open the public IP on the browser, and you would get the default page of one of the VMs. As the idle time to wait is 4 minutes, then refresh you would get the other VM’s default page as shown here. It is not necessary that the default page loading is in sequence. Actually, it is randomly changed between healthy nodes. And so, you may expect to get back to the last VM page which came before. These VMs are in different zones and so zone redundancy is maintained.

VM-1 page loaded
Vm-3 page loaded
VM-2 page loaded

Conclusion

This was to practice the use zone-redundant load balancer. We can create a complete network infrastructure as per requirements. You can go to references for more understanding.

Note: Do not forget to delete the resource group to delete all resources created.

resource group deletion

References

  1. https://learn.microsoft.com/en-us/azure/load-balancer/load-balancer-standard-availability-zones#zone-redundant
  2. https://learn.microsoft.com/en-us/azure/reliability/availability-zones-overview
  3. https://learn.microsoft.com/en-us/azure/load-balancer/quickstart-load-balancer-standard-public-portal
  4. https://blog.knoldus.com/how-to-create-resources-using-an-arm-template-locally/
knoldus footer

Written by 

Vaibhav Kumar is a DevOps Engineer at Knoldus | Part of Nashtech with experience in architecting and automating integral deployments over infrastructure. Proficient in Jenkins, Git, AWS and in developing CI pipelines. Able to perform configuration management using ansible and infrastructure management using terraform. Like to script and do developing in Python. Other than AWS, have an experience in Google Cloud, Azure cloud services. Other than Jenkins, CI/CD in Azure Pipelines, GitHub Actions, Teamcity. Loves to explore new technologies and ways to improve work with automation.

Discover more from Knoldus Blogs

Subscribe now to keep reading and get access to the full archive.

Continue reading