Azure
load balancer overview
Load
balancing provides a higher level of availability by spreading
incoming requests across multiple virtual machines.
An Azure load balancer is
a Layer-4 (TCP, UDP) load balancer that provides high availability by
distributing incoming traffic among healthy VMs. A load balancer
health probe monitors a given port on each VM and only distributes
traffic to an operational VM.
You define a front-end IP
configuration that contains one or more public IP addresses. This
front-end IP configuration allows your load balancer and applications
to be accessible over the Internet.
Virtual machines connect
to a load balancer using their virtual network interface card (NIC).
To distribute traffic to the VMs, a back-end address pool contains
the IP addresses of the virtual (NICs) connected to the load
balancer.
To control the flow of
traffic, you define load balancer rules for specific ports and
protocols that map to your VMs.
Configuring
Load Balancer on Azure
Creating the Load Balancer:
- Sign in to Azure Portal.
- Select Create a resource > Networking > Load Balancer on the top left of the screen.
3. In the Create load balancer select the details, for resource select the one which you have created in the last session.
4. Under instance details give a name for your choice and select the region South India.
5. Under public IP address select create new and give the IP address name for your choice and click on Review + Create.
6. Once your validation
gets paused then select Create.
Creating a Backend Address Pool:
To distribute traffic to
the VMs, the load balancer uses a back-end address pool. The backend
address pool contains the IP addresses of the virtual network
interfaces (NICs) that are connected to the load balancer.
To create a back-end
address pool that includes VM1 and VM2:
- Open the load balancer that you have created.
- Under Settings, select Backend pools, and then select Add.
3. On the Add
a backend pool page, type or select the
following values:
- Name: Type BackEndPool.
- Associated to: Drop down and select Availability set.
- Availability set: Select AVSetSouthIndia.
- 4.Select Add a target network IP configuration.
- Add each virtual machine (MyVM1 and MyVM2) that you created to the back-end pool.
- After you add each machine, drop down and select its Network IP configuration. 5.Select OK.
6. On the Backend
pools page, expand MyBackendPool
and make sure both VM1
and VM2 are listed.
Creating a Health Probe:
To allow the load balancer
to monitor VM status, 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.
To create a health
probe to monitor the health of the VMs:
- Under Settings of load balancer, select Health probes, and then select Add.
2. On the Add a health
probe page, type or select the following values:
- Name: Type HealthProbe.
- Protocol: Drop down and select HTTP.
- Port: Type 80.
- Path: Accept / for the default URL. You can replace this value with any other URL.
- Interval: Type 5. Interval is the number of seconds between probe attempts.
- Unhealthy threshold: Type 2. This value is the number of consecutive probe failures that occur before a VM is considered unhealthy.
- 5. Select OK.
Creating a NAT Rule:
To create NAT rule:
- Under Settings of Load Balancer, select Inbound NAT Rules, and then select Add.
2 . Give
a name for the rule and select the load balancer IP. Select the
protocol as HTTP. For
Port give the value as
3441 and select Target
Virtual Machine as VM2
and then select its Network IP configuration. Choose Custom
for port mapping and give target port value as 3389.
3. You
can now find a rule. Again, click on Add
button to add rule for VM2.
4. Give a name for the
rule and select the load balancer IP. Select the protocol as HTTP.
For Port give the
value as 3442 and
select Target Virtual Machine as
VM2 and then select
its Network IP configuration. Choose Custom
for port mapping and give target port value as 3389.
5. These two rules will
help for sharing load between VM1 and VM2 by network address
translating incoming user request.
Creating a load balancer rule:
A
load balancer rule defines how traffic is distributed to the VMs. The
rule defines the front-end IP configuration for incoming traffic, the
back-end IP pool to receive the traffic, and the required source and
destination ports.
The
load balancer rule named LBRule
listens to port 80 in the frontend LoadBalancerFrontEnd.
The rule sends network traffic to the back-end address pool
BackEndPool, also on
port 80.
To create the load
balancer rule:
- Select All resources on the left menu, and then select SouthIndia_LB from the resource list.
- Under Settings, select Load balancing rules, and then select Add.
3. On the Add
load balancing rule page, type or select the
following values:
- Name: Type LBRule.
- Frontend IP address: Select SouthIndia_LBIP.
- Protocol: Select TCP.
- Port: Type 80.
- Backend port: Type 80.
- Backend pool: Select SouthIndiaBackendPool.
- Health probe: Select HealthProbe.
- 4 .Select OK.
5. You can find the rule
that was added now.
6. Go to the overview
page at the Load Balancer menu and copy the IP address and ping it
in the browser. Now you can see that the load is balancing for both
VM1 and VM2. While refreshing you can see the change.
Now, you are all set with
load balancer configured for VM1 and VM2 in South Indian datacentre.
Now the incoming user requests will be equally sent to VM1 and VM2.
Below is the output.
Thank you for visiting our blog.
For Azure, AWS and GCP Training classes in Pune, Mumbai, Thane, click here
Below are some awesome books, you must buy.
Comments
Post a Comment