Load Balancers distribute the incoming traffic over multiple servers. Here, it will distribute the load over two Virtual Machines that I have already created.
- First, click on "Create a Resource", and find Load Balancer under the Networking category.
- Set the name of Load Balancer, keep it Public. Set the Public Address. Create new, keep it dynamic, and give it some name.
- I am using an existing resource group where I have already created two Virtual Machines. Give the location and click on "Create".
- First, we are going to configure Health Probes of our Load Balancer. So, we need to define how many servers we need to make the Load Balancer.
- So, inside Load Balancer, go to Health Probes and click on Add.
- Give name to the Health Probe. The interval shows at it is going to make a probe attempt at five second intervals. And the unhealthy threshold shows that after two failed probe attempts, it is going to declare it as an unhealthy server.
- Now comes the role of Backend Pools.
- In the Backend Pools, we define the servers which we are going to use in the Load Balancer.
- Now click on Backend Pools and click on Add.
- Here I have given some name to my Backend Pool. I have associated it with an availability set that I had created. This AvailSet1 contains two of my VMs. Next, we need to add target network IP configuration.
- First I have selected the VM1 and its network IP configuration.
- Then I have selected the second VM and its IP configuration. Finally click on OK.
- So the backend pool has been configured now. The next step is configuring Load Balancing Rules.
- Click on Load Balancing Rules and click on Add.
- Here I have given some name to the rule. The IP version is IPv4, protocol is TCP, port number is 80, backend port is 80, backend pool is the one that we just created and the health probe is the one that we just created.
- Session persistence is none by default and idle timeout is 4 minutes by default. Floating IP disabled. Click on OK.
- So our Load Balancing Rule has been created.
- Both of my VMs which are under the Load Balancer are in running mode.
- In the Load Balancer, I have my Public IP address. I am going to copy it and paste it in the address bar.
- On the first hit, it has taken me to VM1’s server.
- But if I hit the same address in another browser window, it is taking me to VM2’s server.
- Side by side they would look something like this.