Load Balancing
Algorithms, health checks, and capacity planning
Load balancers are the unsung heroes of high availability. They distribute traffic across servers, detect failures in milliseconds, and ensure no single point of failure. The choice between Layer 4 (TCP) and Layer 7 (HTTP) balancing is a trade-off: L4 handles millions of connections with minimal overhead, while L7 enables smart routing based on content, cookies, or headers.
Algorithm selection matters: use least connections for long-lived requests, round-robin for uniform workloads, and consistent hashing for stateful services. Health checks are critical—configure aggressive timeouts (1-2 seconds) to quickly remove failed servers from rotation.
⚡ Quick Decision
Choose Layer 4 When:
- • Need maximum throughput (>1M RPS)
- • TCP/UDP protocols
- • Minimal latency overhead
Choose Layer 7 When:
- • Need content-based routing
- • SSL termination required
- • A/B testing & canary deploys
Algorithm Choice:
- • Round Robin: Uniform workloads
- • Least Connections: Long-lived requests
- • IP Hash: Session affinity
💡 For implementation guides and code examples: See our comprehensive Proxies & Load Balancing Technology Deep Dive
🏎️ Layer 4 (Transport)
🌐 Layer 7 (Application)
Health Check Types
TCP Check (Basic)
HTTP Check (Recommended)
Configuration Guidelines
⚠️ Critical Health Check Rules
- • Exclude health endpoints from rate limiting
- • Health checks should not modify application state
- • Use separate health check pools for dependencies
- • Monitor health check response times
🔧 Essential Setup
- □Deploy load balancers in HA pairs
- □Configure aggressive health check timeouts
- □Set up monitoring for backend health
- □Enable connection draining for deployments
⚡ Performance Tuning
- □Tune TCP buffer sizes for high throughput
- □Enable connection pooling to backends
- □Configure keep-alive for HTTP/1.1
- □Monitor CPU and memory utilization