A load balancer distributes incoming requests across multiple servers to improve availability, performance, and fault tolerance.
Key Benefits
- Improved availability: If one server fails, requests are routed to healthy servers
- Better performance: Distributes load to prevent any single server from becoming a bottleneck
- Scalability: Enables horizontal scaling by adding more servers behind the load balancer
- Fault tolerance: Automatically detects and routes around failed servers
Common Load Balancing Algorithms
- Round Robin: Distributes requests sequentially across servers
- Least Connections: Routes to the server with fewest active connections
- IP Hash: Routes based on client IP address for session persistence
- Weighted Round Robin: Assigns weights to servers based on capacity
Types of Load Balancers
- Layer 4 (Transport Layer): Routes based on IP and TCP/UDP port
- Layer 7 (Application Layer): Routes based on application data (HTTP headers, cookies, etc.)