What exactly is a Load Balancer?

The success of a web application is shown by the fact that it is used by more and more users. However, this also leads to a steadily increasing load on the servers. To ensure that the application remains performant despite the growing user rush and at the same time to avoid failures, additional servers are needed. Here, a load balancer takes on the task of distributing the payload as efficiently as possible to the servers behind it.

load balancer
 
basic client/server communication
The client sends a request to the server. Each request generates a certain load on the server.

What is the challenge?

A typical web application requires at least one server and one client. The server handles the client's requests by loading or storing data. A client can be a web browser on a PC or an app on a smartphone. For example, when you visit a particular website in your browser, it sends a request to the server. The server loads the page and sends it back to the browser. Such requests put a load on the server and take up available hardware resources such as CPU, RAM, hard disk and network traffic.

If only a few clients access the web application, the load on the server remains manageable. However, if more clients access the same application at the same time, the server can be heavily loaded. This can cause the application to become slow for all clients or even fail completely.

servers are overloaded
When many clients simultaneously send numerous requests to the server, it can generate a significant load on the server.

A Load Balancer solves this problem

To solve this problem, applications are often run on multiple servers at the same time, a practice known as clustering. A cluster can consist of two or more servers, also called nodes. Each of these nodes is an exact copy with the same capabilities as the others within the same cluster. To efficiently distribute client requests across multiple servers, a load balancer is used. The load balancer ensures that as many client requests as possible are distributed evenly across several servers.

load balancer is the solution
Adding more servers can effectively handle many requests, but a load balancer is essential for efficiently distributing incoming traffic across multiple servers while preventing requests from reaching overloaded or failed ones.

 

Load Balancing algorithms

Depending on the type of application, the load distribution may vary. To adjust the distribution effectively, load balancers offer various algorithms. There are essentially two types of load balancing algorithms: Static and Dynamic. There are numerous different load balancing algorithms, of which the following are likely the most commonly used.

 

static algorithms

Static algorithms are relatively straightforward and do not require any knowledge about the state of the servers. Static load balancing algorithms are often used in environments where server load is relatively constant and does not change frequently.

round-robin algorithm Round-Robin This is the simplest way to distribute the load. In the Round-Robin method, each client request is forwarded to the next server in line.

weighted round-robin algorithm Weighted Round-RobinIn Weighted Round-Robin Load Balancing, servers can be assigned different weights based on priority or capacity. Servers with higher weights receive more requests.

ip-hash algorithm IP-HashWith the IP-Hash method, each client is directly associated with a specific server. Consequently, all subsequent requests from a particular client are directed to the same server.

dynamic algorithms

Dynamic algorithms are more intelligent as they analyze the server load and distribute requests based on these results. Dynamic load balancing algorithms are used in environments where the server load is unpredictable and continuously fluctuates.

least connection algorithm Least ConnectionWith this approach, the load balancer monitors the number of active requests currently being processed on the servers. All new requests are sent to the server with the fewest open requests.

least response algorithm Least Response TimeIn this method, response times from past requests are measured, allowing the server with the fastest processing time to receive the current request.

resource-based algorithm Resource-BasedWith the resource-based method, Load Balancers distribute traffic by proactively analyzing the current server load. The server with the lowest load receives each current request.

 

Various Types of Load Balancers

There are various types of load balancers, including software, hardware, and cloud-based solutions. The choice between these load balancer types primarily depends on where you operate your infrastructure, whether it's in your own data center, in the cloud, or in a hybrid environment.

hardware load balancer Hardware Load Balancer Hardware load balancers are optimised for use in data centres and offer robust performance. They are less prone to software errors and failures as they are specifically designed for their task. However, they are more expensive to purchase and require ongoing maintenance costs. Compared to software or cloud load balancers, they are less customisable and scalable.

software load balancer Software Load Balancer Software load balancers are flexible and cost-effective solutions. They run on existing infrastructure and are easily scalable. Their configuration and management usually require less technical expertise, making them a user-friendly option. However, they reach their limits with very high traffic and can affect performance. They are also somewhat dependent on the underlying hardware.

Cloud Load Balancer

load balancer as a cloud solution

Cloud load balancers offer two key advantages. First, they are typically managed by cloud providers, eliminating the need for installation and updating. Second, they allow for automatic scalability of performance, meaning they can handle extremely high levels of traffic as needed, without intervention from administrators.

However, there is a potential drawback: costs can increase if they are not deployed wisely or with insufficient cost control, as they operate on a pay-as-you-go model.

 

Conclusion

A structure consisting of a cluster with several servers and a load balancer that distributes the load efficiently guarantees maximum availability of the application. In addition, such a setup offers a way to minimise the operating costs of a web application while being prepared for future business growth.