Bookmarks

Load balancer

A device or program that distributes incoming requests across several servers so that none is overloaded and the service stays available if some servers fail.

Also: balancer, load balancing, traffic balancer

checked 9 Nov

All terms

Without a load balancer, the service address points to a single server, which becomes both a bottleneck as load grows and a single point of failure. A load balancer accepts requests on one virtual address and spreads them across a pool of servers, skipping any that don’t respond. This is how services scale horizontally and survive the loss of individual machines without downtime.

L4 and L7

Load balancers work at different network layers, which determines their capabilities and cost. The L4/L7 terms come from the OSI model: L4 sees only connections, while L7 sees application requests.

AspectL4 (transport)L7 (application)
What it seesIP addresses and ports, TCP and UDP streamswhole HTTP requests: paths, headers, cookies
Decisionwhere to send a new connectionwhere to send each request
Overheadminimal: the decision is just choosing an addresshigher: the request has to be parsed and understood
Typical usesTCP services, DNS, games, streamingwebsites and APIs, path-based routing

Distribution algorithms

  • Round robin: requests go in turn, ignoring load; the weighted variant sends more requests to more powerful servers.
  • Least connections: a new request goes to the server with the fewest active connections; suits long sessions (LDAP, SQL) and works less well for short HTTP requests.
  • IP hash: connections from one client always reach the same server (stickiness).
  • Random: a random choice; useful on large farms where servers are added and removed often.

Health checks

The balancer periodically polls servers with health checks and stops sending traffic to any that fail to respond or return an error. It checks a TCP port or a specific URL, for example GET /healthz; the interval, timeout and number of failures are configurable. Autoscaling relies on the same checks: a server that fails them is replaced with a new one.

Sources

the term is written from these pages

Verified 9 Nov

Not to be confused with

what it is mixed up with and how it differs

  • reverse proxy

    A reverse proxy sits in front of a service and does more: it caches, compresses and terminates TLS. Load balancing is just one of its functions.

  • API gateway

    An API gateway works with microservices: routing, authentication, rate limits. A load balancer works a layer below and simply distributes requests.

  • failover

    Failover is switching to a standby node when the primary fails. A load balancer continuously distributes traffic among all working nodes.

In depth in the references

where the topic is covered in detail

Appears in the references