Load balancing refers to efficiently distributing incoming network traffic across a group of servers or services. It improves responsiveness and increases availability of applications.
A load balancer is a device that sits between the client and the server cluster accepting incoming network and application traffic and distributing the traffic across multiple backend servers using various methods. By balancing application requests across multiple servers, a load balancer reduces individual server load and prevents any one application server from becoming a single point of failure, thus improving overall application availability and responsiveness.
On high-level, there are three types of load balancers-
- Hardware-based
- Cloud-based
- Software-based
Hardware-based
It is a dedicated appliance to provide load distribution, and its relevant features. They are expensive but give you full control. Barracuda and TP-Link are 2 of the most used hardware-based Load balancers.
Cloud-based
Cloud load balancing is the process of distributing workloads across multiple computing resources. Cloud load balancing reduces costs associated with document management systems and maximizes availability of resources. It can transfer loads to servers globally as opposed to distributing it across local servers. In the event of a local server outage, cloud load balancing delivers users to the closest regional server without interruption for the user.
Cloud load balancing uses services offered by various computer network companies. AWS, Google Cloud and Azure are few of the most used Cloud-based Load Balancers in the industry today.
Software-based
One can install, manage and configure LB software themselves mostly used to distribute load across local servers.
HAProxy, Varnish, Balance, Kemp, Nexus are some of most notable Software Load Balancers.
Load Balancing in OSI model
Load balancing can be performed at various layers in the Open Systems Interconnection (OSI) Reference Model for networking.

Layer 4 (Transport Layer) load balancing

It operates at the intermediate transport layer, which deals with delivery of messages with no regard to the content of the messages. A layer 4 load-balancer takes routing decision based on IPs and TCP or UDP ports. It has a packet view of the traffic exchanged between the client and a server which means it takes decisions packet by packet. Layer 4 load balancers simply forward network packets to and from the upstream server without inspecting the content of the packets. They can make limited routing decisions by inspecting the first few packets in the TCP stream.
Layer 7 (Application Layer) load balancing
It operates at the high‑level application layer, which deals with the actual content of each message. HTTP is the predominant Layer 7 protocol for website traffic on the Internet. Layer 7 load balancers route network traffic in a much more sophisticated way than Layer 4 load balancers, particularly applicable to TCP‑based traffic such as HTTP. A Layer 7 load balancer terminates the network traffic and reads the message within. It can make a load‑balancing decision based on the content of the message (Example: URL or cookie). It then makes a new TCP connection to the selected upstream server and writes the request to the server. Let’s take an example-

A user visits a high‑traffic website. Over the course of the user’s session, he or she might request static content such as images or video, dynamic content such as a news feed, and even transactional information such as order status. Layer 7 load balancing allows the load balancer to route a request based on information in the request itself, such as what kind of content is being requested. So now a request for a video can be routed to the servers that store it and are highly optimized to serve up multimedia content. Requests for transactional information such as a discounted price can be routed to the application server responsible for managing pricing and so on.
Load balancing Algorithms and methods
Load balancing uses various algorithms/methods to select the service to which to redirect each client request. Some of the load balancing algorithms are-
- The Least Connection Method
When a virtual server is configured to use the least connection, it selects the service with the fewest active connections. - The Round Robin Method
This method continuously rotates a list of services that are attached to it. When the virtual server receives a request, it assigns the connection to the first service in the list, and then moves that service to the bottom of the list. - The Least Response Time Method
This method selects the service with the fewest active connections and the lowest average response time. - The Least Bandwidth Method
This method selects the service that is currently serving the least amount of traffic, measured in megabits per second (Mbps). - The Least Packets Method
This method selects the service that has received the fewest packets over a specified period of time.
If you would like to install and explore Load Balancers, there are a few open-source ones available which you may explore like LoadMaster by Kemp, Zevenet, GoBetween and a lot more. A quick google search should turn out a few more. Happy Balancing!
