Load Balancer
Definition
A load balancer distributes incoming network traffic across multiple backend servers (a server pool or cluster) to ensure no single server becomes overwhelmed. It improves availability, reliability, and performance of applications.
Load balancers operate at different layers of the OSI model, with different capabilities at each layer.
Load Balancer Types by OSI Layer
| Layer |
Name |
How it Works |
Example |
| L4 (Transport) |
TCP/UDP |
Routes based on IP + port |
HAProxy, AWS NLB |
| L7 (Application) |
HTTP/HTTPS |
Routes based on URL, headers, cookies |
NGINX, AWS ALB |
Load Balancing Algorithms
| Algorithm |
Description |
Best For |
| Round Robin |
Distribute sequentially to each server |
Equal-capacity servers |
| Weighted Round Robin |
Servers get proportional share |
Different-capacity servers |
| Least Connections |
Send to server with fewest active connections |
Long-lived connections |
| Least Response Time |
Send to fastest-responding server |
Variable response times |
| IP Hash |
Same client IP always goes to same server |
Session persistence |
| Random |
Random server selection |
Simple deployments |
High Availability Patterns
- Active-Passive: One active LB, one standby (failover)
- Active-Active: Multiple LBs serving traffic simultaneously
- Health Checks: Monitor backend server health; remove unhealthy servers
- Session Persistence (Sticky Sessions): Route same user to same backend
Popular Load Balancers
| Tool |
Type |
Notes |
| NGINX |
L7 (HTTP) |
Reverse proxy + load balancer |
| HAProxy |
L4/L7 |
Dedicated load balancer, high performance |
| AWS ALB/NLB |
Cloud |
Application/Network Load Balancer |
| Envoy |
L7 |
Cloud-native, service mesh sidecar |
| Traefik |
L7 |
Docker/Kubernetes-native |
| Keepalived |
VRRP |
HA for virtual IPs (not a LB itself) |
- Cdn — monitors backend server health
- SSL Termination — LB can terminate TLS for backends
References