What is Load Balancing?
Load balancing distributes traffic across multiple servers to improve performance, reliability, and scalability.
Load balancing distributes incoming network traffic across multiple servers. It's like having multiple checkout lanes at a store — instead of everyone waiting in one line, traffic is spread across all lanes to keep things moving fast.
Why It Matters:
- Performance: No single server gets overwhelmed
- Reliability: If one server fails, others handle traffic
- Scalability: Add more servers to handle more traffic
- Efficiency: Better resource utilization
Load Balancing Algorithms:
- Round robin: Distribute requests evenly in rotation
- Least connections: Send to server with fewest active connections
- IP hash: Route based on client IP (sticky sessions)
- Weighted: Give more traffic to more powerful servers
Types:
- Hardware load balancer: Physical device
- Software load balancer: Runs on servers (like NGINX, HAProxy)
- Cloud load balancer: Managed service (AWS ELB, Cloudflare)
FAQ
Do I need load balancing?
If you have one server handling all traffic, probably not. If you have multiple servers or expect high traffic, yes.
What's session affinity?
Also called sticky sessions — ensures a user's requests go to the same server, important for stateful applications.