Load Balancer
What is it?
A load balancer distributes incoming traffic across multiple servers so no single server gets overwhelmed.
Explain like I'm 5
Why was it created?
One server can only handle so much traffic. Load balancers were created to spread requests across many servers for capacity and reliability.
Where is it used?
- In front of web and API server pools
- Distributing traffic across regions
- Health-checking and removing bad servers
- Blue/green and canary deployments
Why should developers care?
Almost every scalable system sits behind a load balancer. It's a core building block of high-availability architecture.
How does it work?
Clients connect to the load balancer, which forwards each request to one of several backend servers using a strategy (like round-robin or least-connections). It health-checks servers and stops sending traffic to unhealthy ones.
Real-world example
A site running on five web servers puts a load balancer in front; if one server fails its health check, traffic is routed only to the remaining four.
Common use cases
- Scaling out across many servers
- Avoiding single points of failure
- Routing by health and capacity
- Zero-downtime deployments
Advantages
- Spreads load for higher capacity
- Improves availability via failover
- Enables horizontal scaling
- Supports safe deployments
Disadvantages
- Itself must be made redundant
- Adds a network hop
- Session handling needs care
When should you use it?
Whenever you run more than one server for a service.
When should you avoid it?
For a single low-traffic instance where redundancy isn't needed yet.
Alternatives
Related terms
Interview questions
Beginner
- What does a load balancer do?
- Why use more than one server?
Intermediate
- What is a health check?
- What is the difference between round-robin and least-connections?
Senior
- How do you handle sticky sessions behind a load balancer?
- What is the difference between Layer 4 and Layer 7 load balancing?
Common misconceptions
- "A load balancer makes your app faster" — it mainly adds capacity and resilience, not raw speed per request.
- "One load balancer removes all single points of failure" — the balancer itself must be redundant.
Fun facts
- Layer 7 balancers can route based on the request's URL or headers, not just connections.
- Health checks let a balancer quietly drop a failing server without users noticing.
Timeline
- 1990s — Hardware load balancers become common for web scaling
Learning resources
Quick summary
A load balancer spreads traffic across multiple servers, increasing capacity and keeping a service available if some servers fail.
Cheat sheet
- Distributes traffic across servers
- Health-checks and fails over
- Enables horizontal scaling
- Layer 4 vs Layer 7 routing