Load Balancer Explainer
A load balancer distributes client traffic across multiple servers that provide the same service. Users connect to one public name or address, while the load balancer selects a backend and forwards the traffic. This prevents every request from landing on one machine and allows capacity to grow by adding instances. The balancer may be dedicated hardware, software, a cloud service, or a function built into an application platform. Its most important responsibilities are selection, health awareness, and preserving the connection behavior the application expects.
At the transport layer, a balancer can route TCP or UDP flows using addresses, ports, and connection tables. At the application layer, it can terminate HTTP or TLS, inspect the host and path, and send different requests to different pools. A content path might go to image servers while an API path goes to application servers. Terminating encryption lets the balancer apply routing and security rules but requires careful certificate and key management. Some designs pass encrypted traffic through without inspection.
Round robin cycles through available servers. Least-connections favors the server with fewer active sessions. Weighted versions reflect different server capacities, while hashing a client or request attribute can produce stable placement. Response-time and resource-aware methods use measurements. No algorithm sees the future, so a good choice depends on workload: one long request can cost more than many short ones, and a low connection count does not guarantee an idle processor.
Health checks keep failed or unhealthy servers out of rotation. A basic check may only open a network port, while an application check requests a page and validates the result. Thresholds prevent one lost probe from causing unnecessary removal and require sustained recovery before rejoining. A server can also be drained so existing sessions finish while new traffic goes elsewhere. Poorly designed checks can declare success when a critical dependency is broken or overload the system they are meant to observe.
Stateless applications can serve any request from any instance, which makes balancing simple. Stateful systems may require session affinity, sometimes called sticky sessions, so later requests return to the same backend. Affinity can use a cookie, source hash, or connection identity, but it creates uneven load and complicates failover. Moving session state into a shared service or encoding it securely in the client reduces dependence on one server, though the shared store becomes another component to scale.
The balancer itself must not become a single point of failure. Production systems use redundant instances, health-based routing, anycast, or managed services across zones and regions. Connection state may need synchronization during failover. Capacity planning includes packets per second, new connection rate, encryption work, memory for state, and backend bandwidth. Logs and metrics reveal rejected connections, retries, queueing, and uneven distribution.
Load balancing is therefore a feedback-driven forwarding decision. The front end accepts traffic, policy identifies an eligible pool, an algorithm selects a healthy target, and state keeps packets or related requests consistent. Health checks and draining adapt the pool as servers change. The technique improves scale and availability, but it cannot make an unhealthy application correct. It works best when services expose meaningful health, tolerate retries, and keep shared dependencies from becoming the next bottleneck.
A reverse proxy is a server that receives requests on behalf of one or more backend applications. To visitors it appears to be the site, while it forwards work to internal services.
It can terminate encrypted connections, route paths to different services, cache content, compress responses, and apply basic traffic controls. This gives backend applications a simpler and more protected entry point.
Incorrect forwarding headers, routing rules, or trust settings can expose the wrong service or break application behavior. A reverse proxy also needs capacity and redundancy because it can become a critical entry point.
Explore more "Explainers"
Discover additional explainers across politics, science, business, technology, and other fields. Each explainer breaks down a complex idea into clear, everyday language—helping you better understand how major concepts, systems, and debates shape the world around us.
