So let’s start with what Load Balancing refers to, it refers to efficiently distributing incoming network traffic across a bunch of back end servers, It’s also commonly known as a server farm or server pool.
Most of modern high traffic websites have to serve thousands or even millions of concurrent requests from users or clients, then return the correct text, video, images, or application data, in a very fast and consistent and reliable manner. In order for cost-effectively scale to get these high volumes, modern computing best practice usually needs appending additional servers.
A load balancer serves as the “traffic cop” sitting in front of your servers, then routing client requests aboard all servers suited of executing these requests in a manner which maximizes the speed and capacity utilization and makes sure that nobody’s server is overworked, as it can degrade performance. Once a single server goes down, the load balancer redirects traffic to the servers that are currently online. Once a new server is added to the server group, the load balancer immediately begins sending requests to it.
In this manner, a load balancer is capable of executing the following functions:
– Distributing client requests, or network load efficiently across numerous servers.
– Assures high availability and reliability by sending requests specifically to servers that are online.
– Grants flexibility to add or detract servers as demand dictates.
Load Balancing Algorithms
Various load balancing algorithms grant different benefits, the choice of load balancing method is dependent on what you need.
– Round Robin – Requests are given across the group of servers constantly.
– Least Connections – A new request is sent to the server with the least current connections to clients. The relative computing capacity of every server is divided into determining what one has the least connections.
– IP Hash – The IP address of the client is used to determine what server gets the request.
Usually the information of a user’s session is stored locally in the browser. As an example, in a shopping cart application the items in a user’s cart may be stored at the browser level until the user is prepared to purchase them. Switching what server receives requests from that client in the middle of the shopping session could create performance issues or a complete transaction failure. Whenever a case like that happens, it is important that all requests from a client are sent to the same server for the time of the session. This is known as session persistence.
Generally, the best load balancers should be able to handle session persistence as required. A different use case for session persistence is when an upstream server stores information requested by a user in its cache to improve performance. Changing servers could cause that information to be retrieved for the second time, causing performance inefficiencies.
Hardware vs. Software Load Balancing
Load balancers usually come in two flavors: hardware-based and software-based. Sellers of hardware-based solutions load proprietary software onto the machine they give, which tends to use specialized processors. To endure increasing traffic on your website, you need to purchase more or bigger machines from the seller. Software solutions usually run on commodity hardware, causing them to be less expensive and more flexible. You could install the software on the hardware of your choice or in cloud environments like AWS EC2.