What Is a Load Balancer?

September 6, 2025
4 min read
1 tag
#system-design
"A load balancer distributes incoming network or application traffic across multiple servers to ensure no single server gets overwhelmed. This improves performance, reliability, and availability"

Why Use a Load Balancer?

  • High Availability: If one server fails, traffic can be redirected to others.
  • Better Performance: Requests are shared among multiple servers.
  • Scalability: Easy to add/remove servers based on traffic demand.

How It Works

Imagine 3 servers handling web requests. Without a load balancer, all users hit Server-1 → slow and unstable.

With a load balancer:

The load balancer decides which server handles each request.


Example

Imagine 3 web servers:

ServerCurrent Connections
Server-15
Server-22
Server-33

Least Connections algorithm → next request goes to Server-2.


Health Checks

Load balancers often check server health automatically.

  • If a server fails → traffic is redirected to healthy servers.

Load Balancing Algorithms

A load balancer can use different algorithms to decide where each request goes. Here are the most common ones:


1. Round Robin

How it works:

  • Requests are sent to servers in order, one after another.
  • After the last server, it starts again from the first.

Example:

3 servers: S1, S2, S3 Incoming requests: R1, R2, R3, R4, R5

RequestServer Assigned
R1S1
R2S2
R3S3
R4S1
R5S2

✅ Simple and fair for servers with similar capacity.


2. Least Connections

How it works:

  • The server with the fewest active connections gets the next request.
  • Good for servers where request processing time varies.

Example:

ServerActive ConnectionsNext Request Goes To
S15
S22R1 → S2
S33

✅ Balances load dynamically based on current server usage.


3. IP Hash

How it works:

  • Uses the client’s IP address to decide which server handles the request.
  • Same client always goes to the same server (sticky session).

Example:

Client IP → Hash → Server

Client IPServer Assigned
192.168.1.10S2
192.168.1.11S3
192.168.1.10S2(same as before)

✅ Useful for session persistence, where users need to stay connected to the same server.


Summary

AlgorithmHow it WorksWhen to Use
Round RobinRequests in orderServers have similar capacity
Least ConnectionsFewest active connectionsUneven request load / heavy tasks
IP HashClient IP decides serverSession persistence / sticky sessions

Key Benefits of Load Balancers:

  • Distributes traffic to multiple servers.
  • Prevents single-server overload.
  • Improves performance, availability, and reliability.
  • Performs health checks to avoid sending requests to failed servers.
Was this helpful?
Your feedback helps us create better content