What is load balancing ?
Load balancing is an effective way of distributing traffic across group of servers in the backend.. We can also refer these group of backend servers as server pool or server farm.. Load balancing can also be seen in the real life situation too.. You must be confused, let me put it in simple with an example of a joint family where there are more helping hands who work and shares their responsibilities to take care of their loves ones, so the load is distributed among them..
Why is Server Load Balancing necessary?
Server load balancing becomes necessary in situations where there is high traffic on a server than the server can serve. This may be because of the hardware limitation, so load balancing becomes first choice to put a similar of same or higher configuration parallel to the current server and shape the traffic to it, so the traffic is distributed among them..
A family of more members and only one person who works to fulfill the daily needs of the family member. There will be situation when one person's income will not be sufficient for some needs and the family has to compromise on it, however, if another person of the same family starts working, this will take some pressure off from the first person who was working alone for years.. this is nothing but load balancing and now since one more member added to the working member list, the quality of life the family requires can be fulfilled.. Similarly, one server with high number of requests cannot give you the quality of service you are seek at times and the result of this will be that you start losing traffic because of unavailability of service when the user wanted and with load balancing, you will have another server in place to serve those requests which one server was not able to handle on time, i.e., distributed load, so your client's will always get your service when they require, no matter how many users are connected to you at the same time.
If you have a shopping website where you have thousands of products for sale and users coming to your website, ordering the stuff will generate revenue for you and will be the source of income for you.. You will require more and more users to come and shop to increase your earnings and for this, you upgrading your server all the time may not be possible, as it will be considered as ever growing stuff.. One day or the other, you will find your server not capable of serving high requests since your client's did not get to you when they wanted and moved to another shopping site. A web server should always be ready to serve the requests to avoid users going elsewhere because of your server not serving them. Putting such websites on a load balancer infrastructure will make sure that all the requests coming will be serve either by one server or the other, but it will not drop it..
Now, let us know how the load balancing is done and what the different models that can be implemented, of course we can customize it as per our need, but that is based on your requirements..
Load Balancing Models
Load Balancing Model - 1: This is the most standard model available to implement where there are 2 web servers and 1 database server to serve in your infrastructure.. Your server is connected to a load balancer, which will be the first point of contact for your users and the load balancer will then decide where to send the requests based on the configuration we do in it.. Now, the load balancer can be a service from a third-party provider or you can have an independent server or a VPS also.. This is the most effective load balancing scenario, of course, you can customize it to give you more power, but this is the basic one to start with.. Later on if you want you can add in web server and database servers if warranted..
Users on the Internet connect to your website, your website points to your load balancer IP address. Now, the load balancer will take the user's request and then check its algorithms and then decide what it has to do with the request whether to send it to Server A or Server B.. Now, at this point in time a question may have arrived in your mind if you would have been carefully reading this section of the article, if I said that the load balancer will be sending out the request to the Server A and Server B, what is Server B is down at the very moment? What will happen, will my user lose the connection? then what is the user of load balancer? Cool down buddy, you may be getting carried away.. Let me answer you, load balancer (if configured) does a small check of server availability before it sends in a request to it, so none of your users requests are going to offline server, only the online server will serve it.. This must be satisfying to you now, isn't it.. Once the request reaches the online server, it does process it, sends it to the Database Server, gets it back to same server, to the client back..
I hope this has been informative to you and I would like to thank you for reading..