What is a Load Balancer?
The internet has made a lasting impression across the globe and its reach shows no signs of slowing down. Year after year, millions of new users are added to the digital ecosystem. One in which billions of users are already transacting, socializing, and requesting information. When you start to consider the shear magnitude of those figures, it's not hard to believe that this type of volume could put a strain on the backend services of popular websites – especially the likes of Google.
To accommodate the scale of these requests, multiple servers are needed to facilitate the exchange of data. However, the act of adding multiple servers doesn't quite fix the problem because there is the idea of performance that we haven't factored in yet. Even with the additional support, user requests can surge and overwhelm server resources. In order to manage network traffic and limit any degradation to the server, load balancers are installed to ensure only the optimal volume of incoming requests is distributed to a single server.
Though likely obvious to most of you reading this, the network traffic is known as the load. As the days, weeks, and months pass, and a website's load will ebb and flow throughout the year. It's safe to assume that load balancers are likely closer to capacity during the holidays versus less eventful times of the year. Which only gets increasing complicated for multinational organizations orchestrating global load balancing.
If the load exceeds the capacity of a single server, a load balancer responds by distributing the incoming network traffic across multiple servers. But load balancing technology isn't exclusive to backend servers. Load balancers can also perform the same process for web applications, application programming interfaces (APIs), and software-as-a-service (SaaS) applications. With that said, 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.
Types of load balancing: Hardware- vs software-based
There is essentially two types of load balancing – hardware load balancers or software load balancers. 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 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.