What Is a Load Balancer? The Traffic Cop That Keeps Your Site Online
✦ Key takeaways
- A load balancer spreads requests across multiple servers so no single server is overloaded.
- It raises availability: if a server fails, it automatically routes visitors to healthy ones.
- It uses algorithms like Round Robin and Least Connections to decide where to send traffic.
- It works at Layer 4 (transport) or Layer 7 (application) depending on need.
A load balancer is a device or software service that sits between visitors and your servers and spreads incoming requests across multiple servers instead of pouring them all onto one. Picture a traffic cop at a busy junction: they direct each car to the least congested lane so traffic keeps flowing.
Without a load balancer, a single server becomes a double weak point: if traffic spikes it slows or crashes, and if it fails your whole site goes down. A balancer solves both — it spreads the load to avoid bottlenecks, and it routes visitors away from any server that goes down.
Invoice & Quotation Maker
Professional invoices that auto-calc & print/PDF in a minute.
How it decides where to send a request
| Algorithm | How it works | Best for |
|---|---|---|
| Round Robin | Rotates through servers in order | Equally capable servers |
| Least Connections | Sends to the server with fewest active connections | Sessions of varying length |
| IP Hash | Ties each visitor to a fixed server by their address | When session stickiness is needed |
| Weighted | Gives stronger servers a bigger share | Unequal servers |
Health checks
A load balancer doesn't distribute blindly; it constantly checks its servers by sending periodic test requests. If a server stops responding, the balancer temporarily removes it from the pool and routes requests to healthy servers, then adds it back automatically once it recovers. This mechanism is the heart of high availability.
Layer 4 vs Layer 7
A Layer 4 (L4) balancer works at the transport level (TCP/UDP), distributing quickly based on IP addresses and ports without inspecting request content. A Layer 7 (L7) balancer understands HTTP content, so it can route based on the URL, cookies, or content type (for example, sending image requests to dedicated servers). L7 is smarter but slightly heavier.
A scaling example
An online store normally gets 1,000 visitors a minute across two servers. On a sale day the number jumps to 10,000. With a load balancer, you simply add new servers behind it (horizontal scaling) and traffic is spread across them automatically. Without it, the two servers would crash and sales would be lost on the most important day.
Where you'll find them
Load balancers exist as physical appliances in data centers, as open-source software like NGINX and HAProxy, and as managed cloud services such as AWS, Google Cloud, and Azure load balancers. For any site aiming to grow and stay online, a balancer isn't a luxury but a foundation of the architecture.