What is a Load Balancer?
The volume of visitors to a website can rise and fall dramatically even in a matter of seconds. The number of users interacting with the website is also known as the load. If the load exceeds the capacity of a single server, a load balancer responds by distributing the incoming network traffic across multiple servers. It can also perform the same process for web applications, application programming interfaces (APIs), and software-as-a-service (SaaS) applications. This article explores how load balancers work and the reasons why they are so critical for delivering a good user experience.
How do load balancers work?
A load balancer functions like a network traffic cop. It routes client requests, such as for web page views, to the servers that are best able to fulfill those requests. If a server starts overheating and cannot respond quickly enough, the load balancer will divert the traffic load to another server.
This is also true if a server goes down. Working this way, the load balancer can ensure high availability (HA) and reliability. Load balancers give system admins the ability to add or remove servers based on the traffic load. In some cases, this server deployment process is automated.
Load balancers work using algorithms. A static load-balancing algorithm is designed to distribute workloads without considering the state of the system. The “round robin” DNS is an example of this approach to load balancing, as is the client-side random load balancing method.
A load balancer running a static algorithm is not aware of how each server is performing. It simply assigns the load based on a set of preset instructions. The advantage of static algorithms is that they are relatively easy to set up. However, given their potential to send traffic load to busy or offline servers can be problematic or inefficient.
A dynamic load balancing algorithm, in contrast, does take into account the servers’ availability, workload, and performance/health. A dynamic load balancer can shift traffic from a server that’s running hot to one that’s underutilized. A variety of dynamic load-balancing methods are in use. Some are resource-based and geolocation-based. Others are known as “least connection,” which routes traffic to the server with the fewest sessions in progress. Dynamic load balancing can result in better overall quality of service (QoS). Though dynamic load balancers can be challenging to set up and manage.
Why is load balancing necessary?
Load balancing is necessary for a variety of reasons that fall into two broad categories: technical and business. Technically, load balancing is needed to protect web-based systems from outages caused by a single point of failure. It prevents traffic bottlenecks and mitigates the risk of distributed denial-of-service (DDoS) attacks. Legitimate users get uninterrupted access to a website or web app’s services.
In business terms, load balancing is about delivering a consistent, positive user experience. An e-commerce store, for example, might want every customer to enjoy rapid response times from the site and shopping cart. Without load balancing, the merchant runs the risk of customers experiencing delays and unreliable service. This could potentially lead them to abandon the site. In some cases, the business may have a service level agreement (SLAs) or guaranteed QoS established for the web hosting provider. Load balancing enables the hosting provider to adhere to the terms of the SLA.
Hardware- vs software-based load balancers
Load balancers can be hardware- or software-based. Each has its good and bad points, depending on the workload and needs of the organization that deploys it. Hardware load balancers are best for rapidly handling large volumes of traffic from diverse sources. This is because they are usually built on high-performance appliances.
Software-based load balancers are more flexible, offering the same functionality as their hardware peers while running on standard hypervisors. They can easily be reconfigured to meet changes in load characteristics. They also help save rack space in data centers, which is quite helpful for organizations that are space constrained.
What are some of the common load-balancing solutions?
There are several different types of load balancers beyond hardware- versus software-based:
- A Layer 4 (L4) load balancer, referring to its position on the OSI stack, operates at the network transport layer. It makes routing decisions about packets based on TCP or UDP ports, taking source IP addresses and destinations into account.
- A Layer 7 (L7) load balancer works higher up the OSI stack at the application layer. In this position, the load balancer is able to assess the traffic load using a broader range of data than is possible at L4. It can examine HTTP headers and SSL session IDs, for example, to determine how to distribute requests amongst target servers.
- A global server load-balancing (GSLB) load balancer extends the capabilities of L4 and L7 load balancers to spread the load across multiple data centers. This approach is helpful in cases where geographically distributed computing resources are available to accommodate significant changes in load.
Where there is a load, there will be load balancers. The technology is varied and flexible. Hardware-based and software-based load balancers each have their best use cases. Static load-balancing algorithms may not be optimal in all cases. But they are easier to set up than dynamic load-balancing algorithms. Choosing the right placement of the load-balancing function on the OSI stack provides further flexibility in addressing load management workloads. It seems that whatever the load-balancing challenge, a solution is available.