For many large websites and online applications, traffic can be somewhat overwhelming at peak times. To ensure application resiliency, it’s key that this web traffic be well distributed. There is no better device than a load balancer to do the trick.
The modern high-traffic website faces thousands of concurrent requests from users and must return correct application data, video, images, or text in a fast and reliable manner. When the load on a website increases, it leads to the addition of new servers. To manage the new as well as the old server, a Load Balancer comes into play. Acting as the traffic cop, the load balancer routes client requests across all servers to maximize capacity utilization and speed.
The load balancer sits in between the server and the client, accepting all incoming application and network traffic. Using various methods, the load balancer tends to distribute the traffic effectively across multiple backend servers. This is to ensure that any particular server is not overworked, which would lead to a single point failure. In short, a load balancer performs the following functions
- If the need arises, it provides the flexibility to add or remove servers.
- To improve reliability and ensure availability, it will send requests only to those servers that are online.
- Distributes network load or client requests effectively across several servers.
How Does a Load Balancer Work?
There are different algorithms that a load balancer uses in order to be productive and effective. The load of the algorithm depends on your needs.
IP Hash: This algorithm targets the IP address of the client. It uses that particular IP address to determine which server should receive the request.
Least Connections: The request is sent to the server that has least connections to the clients. Load Balancer keeps the computing capacity of each server in mind before determining which server has the least connections.
Round Robin: Load Balancer will distribute clients over a group of servers sequentially.
A good load balancer should have the ability to manage session persistence. What exactly is session persistence? Information regarding user’s session is mostly stored locally in the browser. For example, if a user is has something in their e-commerce carts, it tends to remain there locally on the browser. It does not leave until the user is ready to purchase the item. Now a change of server during a shopping session is going to cause performance issues and transaction failure. Therefore, the user should get the same server until the end of the session.
Hardware vs. Software Load Balancer
There are typically two types of load balancers: software based and hardware based. When a vendor opts for a hardware-based load balancer it tends to a proprietary software on a machine. The machine tends to use specialized processors. To deal with increasing traffic, you will have to buy more machinery. A software-based solution runs on commodity hardware. You can install the software in a cloud environment or hardware of your choice.
Dynamic Configuration of Servers
The fast-changing applications require addition and subtraction of servers constantly. A good load balancer should be able to handle such situations to perfection. It should have the ability to dynamically reduce and remove servers without disturbing the existing connections.
In short, a load balancer acts as a traffic cop to efficiently distribute user traffic across servers. This is absolutely key to the performance on any large web site or application.