17) Quick start to configure Load Balancer:

With Azure Load Balancer, you can spread user requests across multiple virtual machines or other services. That way, you can scale the app to larger sizes than a single virtual machine can support, and you ensure that users get service, even when a virtual machine fails.

1. Distribute traffic with Azure Load Balancer

Azure Load Balancer is a service you can use to distribute traffic across multiple virtual machines. Use Load Balancer to scale applications and create high availability for your virtual machines and services. Load balancers use a hash-based distribution algorithm. By default, a five-tuple hash is used to map traffic to available servers. The hash is made from the following elements:

Source IP: The IP address of the requesting client.

Source port: The port of the requesting client.

Destination IP: The destination IP of the request.

Destination port: The destination port of the request.

Protocol type: The specified protocol type, TCP or UDP.

Image

Load Balancer supports inbound and outbound scenarios, provides low latency and high throughput, and scales up to millions of flows for all TCP and UDP applications. Load balancers aren't physical instances. Load balancer objects are used to express how Azure configures its infrastructure to meet your requirements.

To achieve high availability with Load Balancer, you can choose to use availability sets and availability zones to ensure that virtual machines are always available:

2. Select the right Load Balancer product

Two products are available when you create a load balancer in Azure: basic load balancers and standard load balancers.

 

a) Basic load balancers allow:

 

b) Standard load balancers support all of the basic features. They also allow:

 

3. Internal and external load balancers

 

 

4. Create a public load balancer to load balance VMs using the Azure portal

Standard load balancer resources created for quickstart.

In this section, you create a load balancer that load balances virtual machines. When you create a public load balancer, you create a new public IP address that is configured as the frontend (named as LoadBalancerFrontend by default) for the load balancer.

 

Image

Create a standard load balancer

 

5. Create a backend address pool

To distribute traffic to the VMs, a backend address pool contains the IP addresses of the virtual (NICs) connected to the Load Balancer. Create the backend address pool myBackendPool to include virtual machines for load-balancing internet traffic.

 

6. Create a health probe:

To allow the Load Balancer to monitor the status of your app, you use a health probe. The health probe dynamically adds or removes VMs from the Load Balancer rotation based on their response to health checks. Create a health probe myHealthProbe to monitor the health of the VMs.

Image

7. 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, along with the required source and destination port. Create a Load Balancer rule myLoadBalancerRuleWeb for listening to port 80 in the frontend FrontendLoadBalancer and sending load-balanced network traffic to the backend address pool myBackEndPool also using port 80.

Image

8. Create backend virtual network

Next, you will create a backend virtual network, You'll need to replace the following parameters in the steps with the information below:

Image

Image

Image

Image

9. Create backend virtual machines

Standard Load Balancer only supports VMs with Standard IP addresses in the backend pool. In this section, you will create three VMs (myVM1, myVM2, and myVM3) with a Standard public IP address in three different zones (Zone 1, Zone 2, and Zone 3) that are added to the backend pool of the Standard Load Balancer that was created earlier.

 

Image

Image

10. Create network security group rule

In this section, you create a network security group rule to allow inbound connections using HTTP.

Image

 

11. Install IIS on VMs

 

 

 

 

 

 

 

# install IIS server role

Install-Windows Feature -name Web-Server -IncludeManagementTools

 

# remove default htm file

remove-item C:\inetpub\wwwroot\iisstart.htm

 

# Add a new htm file that displays server name

Add-Content -Path "C:\inetpub\wwwroot\iisstart.htm" -Value $("Hello World from " + $env:computername)

Image

 

12. Test the Load Balancer

Image

13. Remove VM from a backend pool

 

With myVM1 no longer in the backend address pool, you can perform any maintenance tasks on myVM1, such as installing software updates. In the absence of VM1, the load is now balanced across myVM2 and myVM3.

14. Add VM to a backend pool

To add myVM1 back to the backend pool, complete the following steps: