Load Balancer in Azure

Free AWS Course for AWS Certified Cloud Practitioner (CLF-C01) Start Now!!

We offer you a brighter future with FREE online courses - Start Now!!

Users love Azure as their organization’s webpage is constantly available for their clients. But they are always worried about the sudden rise in traffic and due to which their clients cannot access the resources. The solution for this issue is Load Balancer. In today’s article, we will talk about Microsoft Azure Load Balancer. Let us begin.

What is Azure Load Balancer?

The load balancer is responsible for distributing incoming traffic to the virtual machine pool. It halts traffic routing to a failed virtual machine in the pool.

We can make our application resilient to any software or hardware failures in that pool of virtual machines this way.

Layer 4 of the Open Systems Interconnection (OSI) model is where Azure Load Balancer operates. It serves as the client’s single point of contact.

The load balancer distributes inbound flows to backend pool instances that arrive at the load balancer’s front end.

These flows are determined by load-balancing rules and health probes that have been configured.

The instances in the backend pool can be Azure Virtual Machines or instances from a virtual machine scale set.

Public Load Balancer

Outbound connections for virtual machines (VMs) within your virtual network can be provided by a public load balancer.

The connections are possible by converting private IP addresses to public IP addresses. Public Load Balancers are useful to balance internet traffic to your virtual machines.

Private Load Balancer

When we need only private IPs at the frontend, an internal (or private) load balancer is useful.

Internal load balancers distribute traffic within a virtual network. In a hybrid scenario, a load balancer frontend can be accessed via an on-premises network.

Configuring Azure Load Balancer

Front-end IP address configuration: This is the IP address to which incoming traffic will be directed, and employees can have one or more front end IP addresses. They are also referred to as virtual IPs.

Back-end address pool: This is the collection of virtual machines to which traffic will eventually be routed.
Load balancing rules are simply a mapping between the front end IP configuration and the back-end address pool.

Probes: Probes allow us to monitor the health of VM instances. If a health probe is detected, the VM instance will be automatically removed from rotation.

Inbound and outbound NAT rules: NAT rules that define the inbound traffic that flows through the front end IP and is distributed to the backend IP. Outbound rules will send the VM’s private IP address to the load balancer’s public IP address.

Demonstration of Creating an and Working of Azure Load Balancer

Creating a Load Balancer

Follow below steps to create Azure load balancer:

1: Log in to Azure Portal (Before proceeding, please ensure you have a subscription. If you created a free account for the first time, you will automatically receive a FREE TRIAL subscription for one month).

Note: If you’re not sure how to get a free Azure account, visit Azure Free Trial Account to learn more.
If you’re not sure how to create an instance or virtual machine, click Create a Virtual Machine to learn more.

2: On the top, use the search bar to look for Load Balancer, and then select Load Balancer.

3: In the upper left corner of the screen, click Add.

4: In the Basic tab of the page one should choose or provide the information and accept the default settings. Then hit on the Review + Create button.

  • Subscription: Choose a subscription.
  • Resource group: Select Create new and enter the value in the text box.
  • Name: Provide a name
  • Region: Choose the region
  • Type: Select Load Balancer Type
  • SKU: Choose SKU
  • Public IP address: Select Create new option but if you already have a Public IP and wish to use the same then choose the Use existing option.
  • Public IP address name: Enter myPublicIP in the text box.

5: Now, the last step is to click on the Create button and in a few seconds Azure Load Balancer is ready to use.

Creating Azure Virtual Network

Follow below steps to create Azure Virtual Network:

1: In the upper-left corner of the screen, choose to Create a resource > Networking > Virtual network or type Virtual network into the search box.

2: In the Basics tab of Create virtual network, enter or select the following information:

3: At the bottom of the page, click the Next: IP Addresses button. Enter the following information in the IP Addresses tab:

4: In the Subnet name field, type default. Enter this information in the Edit subnet and save it before moving on to the Review + create tab.

Creating Azure Backend Pool

Follow below steps to create azure backend pool:

1: In the left-hand menu, select All services, then All resources, and then select your Load Balancer from the list. In this scenario, our load balancer name is “myLoadBalancer” available in the resources list.

2: Select Backend pools from the Settings menu, then click Add.

3: On the Add, a backend pool page, fill in the following information and click Add.

Creating Azure Health Probe

The load balancer uses a health probe to monitor the status of your app. Based on their responses to health checks, the health probe adds or removes VMs from the load balancer.

Follow below steps to create Azure health Probe:

1: In the left-hand menu, select All services, then All resources, and choose myLoadBalancer from the resources list.

2: Now, Select Health probes from the Settings menu, then click Add.

3: On the Add health probe page, enter the following information and then click OK.

Creating Azure Load Balancer Rule

To define how traffic is distributed to the VMs, a load balancer rule is useful. You specify the frontend IP configuration for incoming traffic as well as the backend IP pool for receiving traffic. The rule specifies the source and destination ports. Follow below steps to create azure load balancer rule:

1: In the left-hand menu, select All services, then All resources, and choose myLoadBalancer from the resources list.

2: Select Load balancing rules from the Settings menu, then click Add.

3: Configure the load-balancing rule using these values, then click OK.

Setting up Azure VMs

Here, you must build two VMs but make sure that both the VMs should be inside an Availability Set and then choose the previously built Vnet inside the networking tab.

Installing IIS for Testing

Follow below steps to install IIS for testing:

1: In the Azure Cloud Shell (PowerShell), execute the following command to install IIS on the virtual machine. Change the Location and Resource Group parameters to match the VM you’ve deployed:

Set-AzVMExtension `

-ResourceGroupName LBresourcegroup `

-ExtensionName IIS `

-VMName myVM1 `

-Publisher Microsoft.Compute `

-ExtensionType CustomScriptExtension `

-TypeHandlerVersion 1.4 `

-SettingString ‘{“commandToExecute”:”powershell Add-WindowsFeature Web-Server; powershell Add-Content -Path \”C:\\inetpub\\wwwroot\\Default.htm\” -Value $($env:computername)”}’ `

-Location WestUS

Adding Virtual Machines to the Backend

Follow below steps to add Azure virtual machines to the backend:

1: In the left-hand menu, select All services, then All resources, and choose myLoadBalancer from the resources list.

2: Go to Settings, then Backend pools, and choose the Backend Pool here we choose myBackendPool.

3: Select myVNet from the Virtual Network and Virtual machines from the Associated to.

4: In the Virtual Machines section, click + Add, then click the newly created both VMs and finally click Save.

Testing the Load Balancer

Follow below steps to test the azure load balancer:

1: On the Load Balancer’s Overview screen, locate the public IP address for the load balancer.

2: Copy the public IP address and paste it into your browser’s address bar. Examine the response. A valid response confirms that the load balancer was successfully created and that it can communicate with the backend VMs. Refresh the browser several times to see connections to both VM1 and myVM2.

Azure Load Balancing Rules

Load balancing rules specify how traffic is routed when it arrives at the load balancer. We can use these rules to route traffic to the backend pool.

You can also enable session persistence, which allows client IP addresses to be routed to the same backend virtual machines.

Features of Azure Load Balancer

1. Load Balancing: The Azure load balancer employs a 5-tuple hash which consists of the source IP, source port, destination IP, destination port, and protocol. Within the load balancer, we can configure a load balancing role based on the source port and source IP address from which the traffic is coming.

2. Port Forwarding: If we have a pool of web servers and don’t want to assign a public IP address to each web server in that pool, we can use the load balancer’s port forwarding feature. If we’re going to perform any maintenance, you’ll need to RDP into those Web servers that have a public IP address.

3. Application-agnostic and Transparent: The load balancer does not interact directly with TCP, UDP, or the application layer. We can route traffic based on URL or multi-site hosting before proceeding to the application gateway.

4. Automatic Reconfiguration: When we scale up or down instances, the load balancer can reconfigure itself. As a result, if we add more virtual machines to the backend pool, the load balancer will automatically reconfigure.

5. Health Probes: As previously discussed, the load balancer can detect any failed virtual machines in the backend pool and stop routing traffic to that failed virtual machine. It will recognise that we can configure a health probe to determine the health of the instances in the backend pool using health probes.

6. Outbound Connection: All outbound flows from a private IP address within our virtual network to public IP addresses on the Internet can be translated to the load balancer’s frontend IP address.

Uses of Azure Load Balancer

Users can easily scale their applications and create highly available services using Azure Load Balancer. Load balancers can handle both inbound and outbound traffic.

Load balancers provide low latency and high throughput for all TCP and UDP applications, and they scale up to millions of flows.

The following are some of the key scenarios that you can achieve with Azure Standard Load Balancer:

  • Internal and external traffic while working with Azure virtual machines should be load balanced.
  • Distribute resources within and across zones to increase availability.
  • Configure Azure virtual machines’ outbound connectivity.
  • Monitor load-balanced resources with health probes.
  • Use port forwarding to connect to virtual machines in a virtual network using a public IP address and port.
  • Enable IPv6 load balancing support.
  • Load balancing services can be provided on multiple ports, multiple IP addresses, or both.
  • Change the location of internal and external load balancer resources across Azure regions.
  • By using HA ports, load-balance TCP and UDP flow on all ports at the same time.

Security in Azure Load Balancer

  • The zero-trust network security model underpins the standard load balancer.
  • Standard Load Balancer is secure by default and integrated into your virtual network.
  • The virtual network is secure and private.
  • Unless opened by Network Security Groups, standard load balancers and standard public IP addresses are closed to inbound connections. NSGs are useful to explicitly allow permitted traffic.
  • Traffic does not reach your virtual machine resource if you do not have an NSG on its subnet or NIC. See Network Security Groups to learn more about NSGs and how to use them in your scenario.
    o By default, the basic load balancer is accessible via the internet.
    o The load balancer does not store any customer information.

Pricing and SLA of Azure Load Balancer

See Load balancer pricing for information on standard load balancer pricing. The basic load balancer is provided free of charge. For more information on load balancers, see SLA. There is no SLA for a basic load balancer.

Conclusion

The Azure load balancer is useful to distribute networking traffic load to backend virtual machines, and its scaling feature adds significant value during high and low loads.

The main advantage of defining load balancing rules in your own way is flexibility. The above-mentioned practical Hands-on aids in the understanding of concepts in greater depth.

You give me 15 seconds I promise you best tutorials
Please share your happy experience on Google

follow dataflair on YouTube

Leave a Reply

Your email address will not be published. Required fields are marked *