Load Balancer and why to use it

Load Balancer and why to use it

Currently the web applications are used by the most business organization worldwide. And the business are depended on the online web applications. In short the Web applications are running and tracking the business. 

While the web applications has much responsibility for the success of the business, what if the server where the application is hosted goes down or the amount of incoming requests can’t be handled by the server. Or the Database server fails. For sure it will show a great impact on the business operations. If it is an e-commerce application like e-bay or kohl then it will lay down the business.

So what can we do to avoid or bypass this instances? Here comes the load balancer as the solution for it. Load balancer is made up of algorithms to check the health of the Server, handle incoming requests and so on.

What is load balancer?

Load balancing is a key component of highly-available infrastructures commonly used to improve the performance and reliability of web sites, applications, databases and other services by distributing the workload across multiple servers.

A normal web infrastructure will look like as below

Just think as a client and how you will feel on the following situations.

  • The user connects to our application, and he gets our application page on his browser. But the DB server has failed. The user can see our application but can’t login or do any transaction.
  • The user tries to connect to our application. Unfortunately the web server has failed. So the user won’t be able to connect to our application.
  • There are several clients connected to our application and no more the server can handle any other incoming requests. But the user is trying to connect to the server. And he won’t get any response from the server. Because server couldn’t handle too many requests. 

As a user you will be irritated and try to find another e-commerce application. Or if you are using it for business purpose you will definitely blame your software provider. 

And now think as the software provider……

You build the application perfectly without any issues. You might have spent many resources on it, more time on it. But now all the efforts are wasted because of not your fault. But actually it is your fault for not thinking of such instances. Always you should provide solutions which can withstand such disasters.

Now let’s see how the load balancer is going to solve this problem.

When you look deep inside the image you can see that there are two servers which are replicated. They both have same app installed in them and the database will be synchronized. And the request is handled by the Load balancer and not the server directly.


Now let’s move into how it is going to work.

The load balancer have some algorithms which can detect the Load on the each server and can do health check.

What it will do when a server DB Fails

Let’s say that the Server 1 DB server has failed. The load balancer will automatically detect the failure (Health check) and redirect the incoming request to the Server 2 until the DB server in the server 1 is rectified. So even if the DB server in one of those server fails the clients won’t get interrupted from using the application. So they will be cool. 


What it will do when a server fails

Let’s say that the whole server 1 has failed. The Load Balancer will check the Server 1 and it comes to know that the Server 1 has failed. So it will automatically redirect it to the Server 2. And the client request will be handled by the Server 2 till the Server 1 get cured fully. Once it is cured the Server 1 will be allowed to handle the request. So the User no need to face any inconvenience.


How the Load balancer does solves the loads of the incoming request.

When there are many incoming requests to the load balancer it checks the nearest server to the incoming request. And it will redirect the request to the nearest server. If the nearest server cannot handle any more request it will redirect the request to the next available server. So that the Servers won’t be overloaded.

For example there are two Servers. One is in America (Server 1) and another one in in Asia (server 2). You are trying to connect the application from Sri Lanka. The request is sent to the Load balancer. And then the load balancer will sent your request to the Server 1 as it is near to you. And if the Server 1 is busy with many requests it will redirect your request to the Server 2. 

In the above diagram you can see two requests made. One is in green color and other is in the Yellow color. The green color requests are directed to the Server 1 and yellow color requests are redirected to the Server 2. Here we assume that both servers are healthy. As both servers are healthy the Load balancer uses the both servers to handle the requests.

The silly questions that will come to our mind.

  1. What if the both server fails???

The servers will be in different location. And if you doubt the two servers then you can buy another server and include in the architecture. So now you will have a 3rd Server. And there will be no chance for the both server to fails. And if so God have to save you. lol.....

And this article talks about the basics of the Load balancer. There are more to dive into deep.

Note : The Cloud Service providers such as Google Cloud Platform, Azure, AWS etc. has the Load Balancer inbuilt for Zones. But when it comes for the Global Load Balancer you have to seek help from the DNS Load balancer. [Let's learn about DNS Load balancer in my next article]


要查看或添加评论,请登录

Yogarajah Vithushan的更多文章

社区洞察

其他会员也浏览了