Quantcast
Channel: Cloud Training Program
Viewing all articles
Browse latest Browse all 1892

Azure Load Balancer Overview & Steps to Setup: Case Study

$
0
0

In this blog post, we are going to cover a case study on How to create a Load Balancer in Azure using the Azure Portal which we will be discussing in detail in our Microsoft Azure Solution Architect [AZ-305] FREE Class (In this FREE class we will talk about AZ-305i.e. Microsoft Azure Solution Architect Certification.

An Azure load balancer is used to distribute traffic loads to backend virtual machines or virtual machine scale sets, by defining your own load balancing rules you can use a load balancer in a more flexible way.

The areas covered in this blog are given below:

  1. What is Azure Load Balancer?
  2. Why Choose Azure Load Balancer?
  3. Azure Load Balancer Types
  4. Features Of Azure Load Balancer
  5. Steps to create an Azure Load Balancer

What Is Azure Load Balancer?

Azure load balancer allows you to distribute traffic to your backend virtual machines. An Azure load balancer provides high availability for your application. The Azure load balancer is a fully managed service itself.

Load Balancer

Why Choose Azure Load Balancer?

With Standard Load Balancer, you can scale your applications and create highly available services. Load balancer supports both inbound and outbound scenarios. A load balancer provides low latency and high throughput and scales up to millions of flows for all TCP and UDP applications.
Some of the key scenarios that you can accomplish using Standard Load Balancer include:
  • Load balance internal and external traffic to Azure virtual machines.
  • Increase availability by distributing resources within and across zones.
  • Use health probes to monitor load-balanced resources.
  • Employ port forwarding to access virtual machines in a virtual network by public IP address and port.
  • Standard Load Balancer provides multi-dimensional metrics through Azure Monitor. These metrics can be filtered, grouped, and broken out for a given dimension. They provide current and historic insights into the performance and health of your service. Resource Health is also supported.
  • Load balance services on multiple ports, multiple IP addresses, or both.

Read about:  What is the difference between Data Science VS Data Analytics.

Azure Load Balancer Types

In Azure, you can create two types of the load balancer

  • Public load balancer
  • Internal/ private load balancer

Public Load Balancer: A public load balancer can be used to load balance internet traffic to virtual machines. It can provide outbound connections for virtual machines (VMs) inside your virtual network.

public load balancer

Also Check: Our previous blog post on Azure Custom Roles

Internal/ Private Load Balancer: An internal (or private) load balancer is used to balance traffic from within a virtual network.

internal load balancer

Along with load balancer, there are two pricing tiers available Basic and Standard

Basic: Basic tier load balancer provides basic features and is restricted to some limits for backend pool size it is restricted to only 300 instances, it’s restricted to a single availability set and it only supports multiple frontends for inbound traffic.

Standard: Standard tier load balancer is generally available and offers higher-scale and new features. It is a paid-for feature using a complex set of consumption-based charges and the Basic tier continues to be free. Also, we can scale out to 1000 instances and can span any virtual machine in a single virtual network, including blends of scale sets, availability sets, and machines.

To know more features of Basic and Standard tier check the official Microsoft Docs

Features Of Azure Load Balancer

Azure load balancer

  • Load Balancing: Azure load balancer uses a 5-tuple hash that contains source IP, source port, destination IP, destination port, and protocol.
  • Outbound connection: All the outbound flows from a private IP address inside our virtual network to public IP addresses on the Internet can be translated to a frontend IP of the load balancer.
  • Automatic reconfiguration: The load balancer is able to reconfigure itself when it scales up or down instances on the basis of conditions. So, if more virtual machines are added into the backend pool, automatically load balancer will reconfigure.
  • Application agnostic and transparent: It doesn’t directly interact with TCP or UDP  protocols. We can route the traffic based on URL or multi-site hosting
  • Health probes: When any failed virtual machines in a load balancer are recognized by the health probe in the backend pool then it stop routing the traffic to that particular failed virtual machine. It can configure a health probe to determine the health of the instances in the backend pool.
  • Port forwarding: The load balancer supports port forwarding ability if we have a pool of web servers, and we don’t want to attach a public IP address for every web server in that pool.

Read more: Basics of the Convolutional Neural Network (CNN) and how we train our CNN’s model on Azure ML service without knowing to code.

Azure Load Balancing Rules

  1. Load balancing rules define how to route traffic when it arrives on the load balancer
  2. These rules can use to redirect traffic into the backend pool
  3. You can also enable session persistence- Here’s client IP’s can be directed to the same backend virtual machines

Load Balancing rules

Overview of Azure storage account, Storage account types, Storage account services, how to create a storage account and how to delete a storage account

[Demo] Steps To Create An Azure Load Balancer 

Here, I am going to demonstrate how we can load balance a web server using Azure standard load balancer. This demo includes the following tasks:

  1. Create Azure load balancer
  2. Create a virtual network
  3. Create a backend pool
  4. Create health probes
  5. Create a load balancer rule
  6. Setup two new windows VM
  7. Install IIS for Testing
  8. Add virtual machines to the backend pool
  9. Testing

Task 1: Create Azure load balancer

Step 1) Log in to Azure Portal (Please make sure you have a subscription before doing all this. If you created a free account for the first time, you’ll already have a FREE TRIAL subscription for 1 month).

Note: If you don’t know how to get a free Azure account then click on Azure Free Trial Account to know more

If you don’t know how to create an instance or virtual machine then click on Create a Virtual Machine  to know more

Step 2) On top use the search bar and search for Load Balancer and then choose Load Balancer

Step 3) On the top left-hand side of the screen, click Add

add

Also Check: How to prepare for Azure Solution Architect Exam

Step 4) In the Basics tab of the Create load balancer page, enter or select the following information, accept the defaults for the remaining settings, and then select Review + create.

  • Subscription: Select your subscription.
  • Resource group: Select Create new and type LBresourcegroup in the text box.
  • Name: Enter myLoadBalancer
  • Region: Select East US
  • Type: Select Public.
  • SKU: Select Basic
  • Public IP address: Select Create new. If you have an existing Public IP you would like to use, select Use existing.
  • Public IP address name: Type myPublicIP in the text box.

create load balancer

Also Check: What is the difference between ExpressRoute vs VPN

Step 5) Now Click On Create and check your Load Balancer Is Created.

lb creation

Also Check: Our blog post on Azure Compute.

Task 2: Create a Virtual Network

Step 1) On the upper-left side of the screen, select Create a resource > Networking > Virtual network or search for Virtual network in the search box.

Step 2) In Create virtual network, enter or select the following information in the Basics tab:

create vnet

Check Out: What is the difference between az 303 and az 304

Step 3) Select the Next: IP Addresses button at the bottom of the page. In the IP Addresses tab, enter this information:

create vnet

Step 4) Under Subnet name, select the word default. In Edit subnet, enter this information and select Save then select the Review + create tab.

create suubnet

Also Check: Our blog post on Microsoft Azure Ad: Everything you need to know.

Task 3: Create a Backend Pool

A backend address pool contains the IP addresses of the virtual (NICs) connected to the load balancer.

Step 1) Select All services in the left-hand menu, select All resources, and then select myLoadBalancer from the resources list.

Step 2) Under Settings, select Backend pools, then select Add.

backend pool

Check Out: Our previous blog post on Azure Cost Management

Step 3) In the Add a backend pool page, enter the following information and then select Add.

create backedend pool

Also Check: Our blog post on Azure Kubernetes Service.

Task 4: Create a Health Probe

The load balancer monitors the status of your app with a health probe. The health probe adds or removes VMs from the load balancer based on their response to health checks.

Step 1) Select All services in the left-hand menu, select All resources, and then select myLoadBalancer from the resources list.

Step 2) Under Settings, select Health probes, then select Add.

add a health probe

Check Out: Our blog post on Availability Zone in Azure

Step 3) Enter the below information in the Add health probe page and then select OK.

create health probe

Also Check: Our previous blog post on Azure Powershell

Task 5: Create a Load Balancer Rule

A load balancer rule is used to define how traffic is distributed to the VMs. You define the frontend IP configuration for the incoming traffic and the backend IP pool to receive the traffic. The source and destination ports are defined in the rule.

Step 1) Select All services in the left-hand menu, select All resources, and then select myLoadBalancer from the resources list.

Step 2) Under Settings, select Load balancing rules, then select Add.

create load balancing rule

Step 3) Use these values to configure the load-balancing rule and then select OK.

add load balancing rule

Check Out: our previous blog post on Azure Interview Questions

Task 6: Setup Two New windows VM

Now you have to create two different ‘Windows Server’ Virtual Machines and to do so you can follow the steps given in this Documentation.

Note: Create both the VMs in an Availability Set and Select the previously created VNet named “myVNet” under the Networking tab.

create VM

Also Read: Our previous blog post on Azure Scale Set.

Task 7: Install IIS for Testing

Install IIS Web Server on the virtual machines to test the load balancer.

Step 1) Run the following command in the Azure Cloud Shell (PowerShell) to install IIS on the virtual machine. Change the Location and Resource Group parameter according to the VM in which you have 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 EastUS

install IIS

Note: Change the -VMName line to “myVM2” for installing IIS on the second Virtual Machine.

Also Read: Azure Front Door vs Application Gateway: to know the major differences between them.

Task 8: Add Virtual Machines to the Backend Pool

Step 1) Select All services in the left-hand menu, select All resources, and then select myLoadBalancer from the resources list.

Step 2) Under Settings, select Backend pools, then select myBackendPool.

Step 3) Select the myVNet in the Virtual Network and Select Virtual machines in Associated to.

add vm to backend pool

Also Check: Our previous blog post on Azure Traffic Manager.

Step 4) In the Virtual machines section, select + Add and then select the newly created both VMs, Select Save.

add vms

Also Check: Our previous blog post on azure vnet peering.

Task 9: Test the Load Balancer

Step 1) Find the public IP address for the load balancer on the Overview screen of the Load Balancer.

test load balancer

Step 2) Copy the public IP address, and then paste it into the address bar of your browser. Check the response. A valid response verifies that the load balancer was successfully created and can successfully connect with the backend VMs.

from vm1

Also Read: Our blog post on Azure ARM Templates

Refresh the browser multiple times and you should see connections to both myVM1 and myVM2.

from vm2

And hence, this confirms the load balancer is working as expected.

Conclusion: Azure load balancer is used to distribute networking traffic load to backend virtual machines, its scaling feature provides great value during higher and lower loads. The flexibility is the major benefit of defining load balancing rules in your own way. The above discussed practical Hands-on helps you to understand concepts in more detail.

References/Related

Next Task For You

In this blog, we have discussed the overview of Azure load balancer and features, we cover all these in detail in our Microsoft Azure Solution Architect training program

Register for our FREE class on Microsoft Azure Solution Architect Certification to know more about what’s included & what to expect in the certification in details

Free Class Image

The post Azure Load Balancer Overview & Steps to Setup: Case Study appeared first on Cloud Training Program.


Viewing all articles
Browse latest Browse all 1892

Trending Articles