Load Balancer
A network gateway that distributes incoming traffic across multiple backend servers while routing around unhealthy nodes
Table of Contents
Interactive Playground
Tap or drag to interact with the demoWhat is Load Balancer?
A network gateway that distributes incoming traffic across multiple backend servers while routing around unhealthy nodes. It is a core concept in Traffic & Scaling within Cloud / DevOps.
Core Principles
A Load Balancer sits between clients and a pool of backend servers, spreading incoming requests across healthy instances so no single machine becomes a bottleneck or single point of failure. By running continuous health checks, it automatically drains traffic away from crashed or degraded nodes, delivering both horizontal scalability and high availability.
Load balancers operate primarily at two network layers: Layer 4 (Transport) balancers route raw TCP/UDP streams at ultra-low latency, while Layer 7 (Application) balancers inspect HTTP paths, headers, and cookies to perform smart path routing, TLS termination, and weighted canary splits.
Practical Takeaways
- Pick the right routing algorithm: Round Robin works well for uniform, fast APIs, whereas Least Connections prevents pile-ups when request durations vary widely (such as AI inference or report generation).
- Keep backend servers stateless: Avoid relying on sticky sessions whenever possible. Externalize session state into Redis or stateless JWT tokens so any backend server can serve any request seamlessly.
- Implement connection draining: During deployments or scale-down, mark the node unhealthy first and allow in-flight requests to finish cleanly instead of killing sockets and returning
502 Bad Gatewayerrors.
Notable Examples
- AWS ALB / NLB & GCP Cloud Load Balancing: Automatically scale and distribute millions of requests per second across cloud availability zones.
- NGINX, HAProxy & Envoy: Industry-standard software load balancers powering Kubernetes Ingress controllers and service meshes.
- Weighted Traffic Splitting: Enables blue-green swaps and canary rollouts directly at the L7 edge.