Load Balancing Algorithms
NetworkingHow a load balancer DECIDES which backend server gets each incoming request.
A hotel front desk has 5 receptionists. How do you decide which receptionist handles the next guest? Round Robin (next in line), Least Connections (whoever is currently least busy), or IP Hash (the same guest always goes to the same receptionist so they remember their preferences)?
Round Robin: Requests are distributed sequentially across servers: server1, server2, server3, server1, server2... Simple, predictable, and even - but ignores the fact that some requests take 1ms while others take 5 seconds. A slow server accumulates a pile of long-running requests while still receiving new ones.
Weighted Round Robin: Each server gets a weight. Server with weight=3 gets 3 requests for every 1 request the weight=1 server gets. Use this when servers have different hardware capacities.
Least Connections: Route to the server with the fewest active connections. Works well when request processing times vary significantly (e.g., some requests are fast API calls, others are slow image processing jobs). Requires the load balancer to track connection counts.
Least Response Time: A sophistication of Least Connections - route to the server with the lowest combination of active connections AND response time. AWS ALB's Least Outstanding Requests uses this principle.
IP Hash: `server = hash(client_ip) % num_servers`. Same client always hits the same server. Enables "sticky sessions" without requiring a session token. Breaks badly when clients are behind NAT (many clients sharing one IP all go to the same server).
Random: Pick a server at random. Statistically equivalent to Round Robin at high volume. Used in some P2P load balancing scenarios.
- Round Robin is almost always the default and fine for homogeneous request patterns.
- Least Connections is better for heterogeneous workloads (mixed fast and slow requests).
- Sticky sessions (IP Hash) should be avoided - use server-side sessions (Redis) instead.
- Layer-4 LBs (TCP level) can only use IP/port - Round Robin or IP Hash.
- Layer-7 LBs (HTTP level) can inspect URLs/headers and route by content (A/B testing, microservice routing).
Curated Curation & Deep Insights
ScaleDojo CertifiedOur system architects are vetting high-quality, authorized video guides for Load Balancing Algorithms with zero third-party platform links.
We are preparing premium, zero-competitor deep-dives for Load Balancing Algorithms. Authorized reading references will appear automatically.