What is a Load Balancer?

Backend developer
Nerd For Tech
Published in
4 min readOct 4, 2021
Photo by Tingey Injury Law Firm on Unsplash

This article examines an important topic of system design, the Load Balancer. Familiarizing ourselves with the fundamental concepts and terminologies of system design would immensely help us in designing a more scalable and robust systems efficiently.

Load balancing is the process of distributing network traffic across multiple servers. This ensures no single server bears too much workload. By spreading the work evenly, load balancing improves application responsiveness. It also increases availability of applications and websites for users. Modern applications cannot run without load balancers.

Load balancers manage the flow of information between the server and an endpoint device (PC, laptop, tablet or smartphone). The server could be on-premises, in a data center or the public cloud. The server can also be physical or virtualized. The load balancer helps servers move data efficiently and prevents server overloads. Load balancers conduct continuous health checks on servers to ensure they can handle requests. If necessary, the load balancer can also remove unhealthy servers from the pool until they are restored. Some load balancers even trigger the creation of new virtualized application servers to cope with increased demand.

Hardware vs. Software Load Balancers

Load balancers typically come in two flavors : hardware‑based and software‑based. Vendors of hardware‑based solutions load proprietary software onto the machine they provide, which often uses specialized processors. To cope with increasing traffic at your website, you have to buy more or bigger machines from the vendor. Software solutions generally run on commodity hardware, making them less expensive and more flexible. You can install the software on the hardware of your choice or in cloud environments like AWS EC2.

Software Load Balancers

Advantages :

  • Flexibility to adjust for changing needs.
  • Ability to scale beyond initial capacity by adding more software instances.
  • Lower cost than purchasing and maintaining physical machines. Software can run on any standard device, which tends to be cheaper.
  • Allows for load balancing in the cloud, which provides a managed, off-site solution that can draw resources from an elastic network of servers. Cloud computing also allows for the flexibility of hybrid hosted and in-house solutions. The main load balancer could be in-house while the backup is a cloud load balancer.

Disadvantages :

  • When scaling beyond initial capacity, there can be some delay while configuring load balancer software.
  • Ongoing costs for upgrades.

Hardware Load Balancers

Advantages :

  • Fast throughput due to software running on specialized processors.
  • Increased security since only the organization can access the servers physically.
  • Fixed cost once purchased.

Disadvantages :

  • Require more staff and expertise to configure and program the physical machines.
  • Inability to scale when the set limit on number of connections has been made. Connections are refused or service degraded until additional machines are purchased and installed.
  • Higher cost for purchase and maintenance of physical network load balancer. Owning a hardware load balancer may also require paying for consultants to manage it.

Dynamic load balancing algorithms

  • Least connection: Checks which servers have the fewest connections open at the time and sends traffic to those servers. This assumes all connections require roughly equal processing power.
  • Weighted least connection: Gives administrators the ability to assign different weights to each server, assuming that some servers can handle more connections than others.
  • Weighted response time: Averages the response time of each server, and combines that with the number of connections each server has open to determine where to send traffic. By sending traffic to the servers with the quickest response time, the algorithm ensures faster service for users.
  • Resource-based: Distributes load based on what resources each server has available at the time. Specialized software (called an “agent”) running on each server measures that server’s available CPU and memory, and the load balancer queries the agent before distributing traffic to that server.

Static load balancing algorithms

  • Round robin: Round robin load balancing distributes traffic to a list of servers in rotation using the Domain Name System (DNS). An authoritative nameserver will have a list of different A records for a domain and provides a different one in response to each DNS query.
  • Weighted round robin: Allows an administrator to assign different weights to each server. Servers deemed able to handle more traffic will receive slightly more. Weighting can be configured within DNS records.
  • IP hash: Combines incoming traffic’s source and destination IP addresses and uses a mathematical function to convert it into a hash. Based on the hash, the connection is assigned to a specific server.

Understanding the concept of Load Balance is utmost important in learning System Design. In future posts, we will discuss how these Load Balancing algorithms are implemented.

--

--