Load Balancers

System Design

Load Balancers

What is Load Balancer?

What is Load Balancer?

When the number of requests in an application increases, it can overload a server which affects system performance.

A single server has limited throughput and resources.

For example, an online marketplace like Amazon. During Black Fridays or the Christmas season, it experiences an unusual surge in traffic. It’s only a matter of seconds before the server gets overloaded, therefore, there is a need to scale to effectively handle the increased demand.

Scaling can be done in two ways, vertically or horizontally. In order to scale horizontally, there is a need for a load balancer.

A load balancer is a device that is used to distribute application traffic across a number of servers. It improves the overall performance of a system by distributing the traffic to different servers, therefore, decreasing the burden on a single server.

A load balancer sits between clients and servers. It routes clients’ requests between servers, ensuring that no single server is overworked which could make an application unavailable and unreliable.

Hardware vs Software Load Balancing

Load balancers typically come in two flavors: software-based or hardware-based. Hardware-based load balancers are physical devices that often come with specialized processors and proprietary software customized for load balancing.

On the other hand, software-based load balancers run on commodity hardware where you can install any type of software load-balancer which makes them less expensive and more flexible.

Benefits of load balancers

  1. Scalability - It enables an application to handle a traffic spike effectively, maintaining a smooth operation and fast responses to clients. This enables an application to be highly available and reliable.

  2. Fault Tolerance - A single point of failure can be eliminated by having multiple servers in your infrastructure. When one server fails, a load balancer will route traffic to an available server. This way, redundancy can be achieved.

  3. Avoiding Downtime - A load balancer will enable you to perform server maintenance without incurring downtime by automatically routing traffic to other available servers. This way you can reduce application downtime and improve system availability.

  4. Improved Security - A load balancer can mitigate DDoS attacks. It will route traffic across the servers in case of a traffic surge. This will protect your application availability, giving the load balancer time to determine whether a spike in traffic is legitimate or not, offering a traffic scrubbing effect by blocking malicious requests.

  5. SSL Decryption - A load balancer can handle any incoming HTTPS connections, decrypting the requests and passing the unencrypted requests on to the web servers. This eliminates the need to install SSL certificates in different back-end web servers by providing a single point of configuration. It also takes the processing load of encryption and decryption away from the web servers.

Load Balancers vs Reverse Proxy

Both are components that sit between clients and servers, accepting requests from the former and delivering responses from the latter. The two are mostly similar, however, a load balancer is commonly deployed when an application needs multiple servers for scalability. A reverse proxy can also be used even in cases where you have a single server in place.

Load Balancers are a key component in improving the performance of a system. It ensures high application availability and reliability by ensuring no single server gets overloaded by distributing traffic giving users a good user experience.

Whenever you're ready

There are 4 ways we can help you become a great backend engineer:

The MB Platform

Join 1000+ backend engineers learning backend engineering. Build real-world backend projects, learn from expert-vetted courses and roadmaps, track your learnings and set schedules, and solve backend engineering tasks, exercises, and challenges.

The MB Academy

The “MB Academy” is a 6-month intensive Advanced Backend Engineering BootCamp to produce great backend engineers.

Join Backend Weekly

If you like post like this, you will absolutely enjoy our exclusive weekly newsletter, Sharing exclusive backend engineering resources to help you become a great Backend Engineer.

Get Backend Jobs

Find over 2,000+ Tailored International Remote Backend Jobs or Reach 50,000+ backend engineers on the #1 Backend Engineering Job Board