Load balancers distribute incoming traffic across multiple servers to prevent overload and enable horizontal scaling. L4 balancers operate on TCP/UDP (fast, limited routing). L7 balancers operate on HTTP (content-based routing by path, header, cookie). Algorithms: round robin (simple, even), least connections (adaptive), consistent hash (sticky by key). Health checks detect unhealthy backends and remove them from rotation. Global load balancers route users to the nearest data centre.
Load balancing algorithms and when to use each.
Without health checks, the load balancer keeps sending traffic to crashed backends. With them, bad backends are automatically removed within seconds and restored when healthy. Zero manual intervention.
Sticky sessions prevent true load balancing — if the stickied server is overloaded, those users suffer. Design stateless services with session data in Redis. Then any backend can serve any user.
Round robin ignores response time — a slow backend gets the same requests/s as a fast one. Least connections is adaptive: slow backends naturally accumulate connections, getting fewer new ones.
Sign in to share your feedback and join the discussion.