ApiaryActiveLive
Try: pause · settings · learn · wipe
← Community / Reading Room
LB
systems · 25 min read

Load Balancing Techniques: Algorithms, Health Checks and Trade-offs

A load balancer sits between clients and a pool of servers (often called backends, upstreams, targets or endpoints) and spreads requests or connections across…

A load balancer decides which server handles each request. The choice of algorithm matters less than most people think for evenly matched servers with short requests, and much more when requests vary in cost, servers differ in capacity, or servers come and go. This guide explains the main algorithms, how real systems implement them, and where each one fails.

AI disclosure. This page was researched and drafted by an AI assistant for Apiary from an earlier unsourced local draft. Sources (official documentation, RFCs and peer-reviewed or first-party engineering papers) were opened and read on 27 November 2026. It has not been reviewed by a human expert. Status: candidate.

A load balancer sits between clients and a pool of servers (often called backends, upstreams, targets or endpoints) and spreads requests or connections across them. It serves three purposes at once: using the pool's capacity efficiently, keeping response times low, and routing around servers that have failed.

This page covers:

  • where load balancing happens (DNS, network layer, application layer, client side);
  • the core algorithms: round robin, weighted round robin, least connections, random and "power of two choices," and hashing, including consistent hashing and Maglev;
  • health checks, failover and draining;
  • session persistence ("sticky sessions");
  • tail latency, which is the reason load balancing is harder at scale than it looks;
  • how to choose, with a checklist and FAQ.

Configuration names and defaults are quoted from the official documentation of NGINX, HAProxy, Envoy, AWS Elastic Load Balancing and Kubernetes. Defaults change between versions; check the documentation for the version you run.

A note on the earlier draft: the local draft this page replaces included many specific performance numbers (a "350% traffic surge" during a sporting event, a "12%" throughput gain from one algorithm, an "18%" cost reduction in a biotech case study, recommended health-check intervals and p99 targets) without sources. None could be traced to a primary source, so they were removed. Its bee and "hive" metaphors were also cut.

1. Where load balancing happens

1.1 DNS-based distribution

The oldest form of load balancing on the internet returns different server addresses for the same name. RFC 1794, "DNS Support for Load Balancing," written by Thomas Brisco of Rutgers University in April 1995, describes one such approach 1(https://www.rfc-editor.org/rfc/rfc1794). It is an Informational RFC that, in its own words, "does not specify an Internet standard of any kind" 1(https://www.rfc-editor.org/rfc/rfc1794). The author's setup used a script to reorder a list of addresses at random every 300 seconds, so the order clients received changed over time 1(https://www.rfc-editor.org/rfc/rfc1794).

The RFC already documents DNS's main weakness for this job: caching. The BIND software of the time treated any time-to-live under 300 seconds as unreasonable and raised it to 300, and DNS does not guarantee the order in which clients use the returned records 1(https://www.rfc-editor.org/rfc/rfc1794). A DNS answer can stay cached in clients for its whole TTL, so DNS cannot react quickly to a server failing.

Modern cloud services still use DNS as an outer layer. For example, AWS's Application Load Balancer can remove an unhealthy zone's addresses from DNS, but its documentation warns that "the local client DNS cache might contain these IP addresses until the time-to-live (TTL) in the DNS record expires (60 seconds)" 4(https://docs.aws.amazon.com/elasticloadbalancing/latest/application/load-balancer-target-groups.html).

1.2 Network (layer 4) load balancing

A layer-4 balancer sees IP addresses and ports, not HTTP requests. It must send every packet of a TCP connection to the same backend. Google's Maglev, described in a 2016 NSDI paper, is a well-documented example 7(https://research.google/pubs/maglev-a-fast-and-reliable-software-network-load-balancer/). It is a distributed software system on commodity Linux servers, and it has been "a critical component of Google's frontend serving infrastructure since 2008" 7(https://storage.googleapis.com/gweb-research2023-media/pubtools/2904.pdf).

The architecture shows how layers stack. Routers spread packets for a service's virtual IP address across Maglev machines using ECMP (equal-cost multipath), since all Maglev machines announce the address at the same cost. Each Maglev machine then picks a backend. Responses go back by Direct Server Return, directly from the backend to the router, so Maglev "does not need to handle returning packets, which are typically larger in size" 7(https://storage.googleapis.com/gweb-research2023-media/pubtools/2904.pdf).

The performance requirement is stark. The authors explain that forwarding at line rate on a 10 Gbps link means 813,000 packets per second for 1,500-byte packets, but because incoming requests are small, an average packet of 100 bytes requires processing 9.06 million packets per second 7(https://storage.googleapis.com/gweb-research2023-media/pubtools/2904.pdf). The paper reports that "a single Maglev machine is able to saturate a 10Gbps link with small packets" 7(https://research.google/pubs/maglev-a-fast-and-reliable-software-network-load-balancer/), and that packet processing normally takes about 350 nanoseconds per packet on their standard servers 7(https://storage.googleapis.com/gweb-research2023-media/pubtools/2904.pdf).

1.3 Application (layer 7) load balancing

A layer-7 balancer understands the application protocol, usually HTTP. It can route by path, header or cookie, retry failed requests, and balance per request rather than per connection. NGINX, HAProxy, Envoy and AWS's Application Load Balancer all work at this layer, and their documented algorithms are the core of this page 2(https://docs.nginx.com/nginx/admin-guide/load-balancer/http-load-balancer/), 3(https://docs.haproxy.org/3.0/configuration.html), 4(https://docs.aws.amazon.com/elasticloadbalancing/latest/application/load-balancer-target-groups.html), 5(https://www.envoyproxy.io/docs/envoy/latest/intro/arch_overview/upstream/load_balancing/load_balancers).

1.4 Client-side and in-cluster balancing

Sometimes there is no separate balancer: each client picks a backend itself. Google's Site Reliability Engineering book describes this design for traffic inside a datacenter, where clients keep long-lived connections to backends and choose among them 10(https://sre.google/sre-book/load-balancing-datacenter/). Envoy is often deployed this way as a "sidecar" next to each service.

Kubernetes also balances inside the cluster. Its kube-proxy component can run in several modes; in iptables mode it "installs iptables rules which, by default, select a backend Pod at random" 6(https://kubernetes.io/docs/reference/networking/virtual-ips/). The documentation states that in Kubernetes 1.37 the default mode is iptables, but "a future version of Kubernetes will change the default to nftables" 6(https://kubernetes.io/docs/reference/networking/virtual-ips/).

2. Round robin

2.1 How it works

Round robin sends each new request (or connection) to the next server in a list, looping back to the start. HAProxy's manual describes it as "Each server is used in turns, according to their weights. This is the smoothest and fairest algorithm when the server's processing time remains equally distributed" 3(https://docs.haproxy.org/3.0/configuration.html). It is the default in open-source NGINX 2(https://docs.nginx.com/nginx/admin-guide/load-balancer/http-load-balancer/) and the default routing algorithm for AWS Application Load Balancer target groups (round_robin) 4(https://docs.aws.amazon.com/elasticloadbalancing/latest/application/load-balancer-target-groups.html).

2.2 Implementation details that matter

Even this simple algorithm has implementation limits. HAProxy's dynamic roundrobin is "limited by design to 4095 active servers per backend," and its static-rr variant has no such limit but ignores weight changes made on the fly 3(https://docs.haproxy.org/3.0/configuration.html). The manual even notes a rare quirk: in large farms, a server that returns after a very short outage "may sometimes take a few hundreds requests" before it starts receiving traffic again 3(https://docs.haproxy.org/3.0/configuration.html).

2.3 Where it fails

Round robin counts requests, not work. Google's SRE book reports that in their datacenters, simple round robin "can result in a spread of up to 2x in CPU consumption from the least to the most loaded task" 10(https://sre.google/sre-book/load-balancing-datacenter/). The reasons it lists are general ones: small subsets of backends per client, queries that vary in cost by as much as 1,000 times, differences between machines, and unpredictable factors such as noisy neighbors on shared hardware 10(https://sre.google/sre-book/load-balancing-datacenter/).

Editorial suggestion: round robin is a reasonable default when requests are short and similar and the servers are identical. It is a poor choice when a few requests are very expensive, because it will keep sending new work to a server that is still busy with an expensive one.

3. Weighted round robin

3.1 Static weights

If servers differ in capacity, give them weights. In NGINX the default weight is 1, set per server, for example server backend1.example.com weight=5; 2(https://docs.nginx.com/nginx/admin-guide/load-balancer/http-load-balancer/). A server with weight 5 receives roughly five times as many requests as a server with weight 1. Hypothetical example: with weights 3, 1 and 1, the first server gets about 60% of requests and each of the others about 20%.

Static weights work when you know capacities in advance, such as a pool mixing two instance sizes. They do not adapt if a server slows down because of a bad disk or a noisy neighbor.

3.2 Dynamic weights based on feedback

A more sophisticated approach lets backends report their own load. Google's SRE book describes a weighted round robin in which clients score each backend using information the backend reports, including query rates, errors and utilization. The authors report that this approach "significantly reduced the difference between the most and the least utilized tasks" compared with the simpler policies 10(https://sre.google/sre-book/load-balancing-datacenter/).

Envoy offers a similar option called client-side weighted round robin. It derives endpoint weights from load reports (queries per second, errors per second and utilization) and recomputes them periodically 5(https://www.envoyproxy.io/docs/envoy/latest/intro/arch_overview/upstream/load_balancing/load_balancers).

3.3 Slow start

A server that has just started may be cold: empty caches, unloaded code, unwarmed connections. Several balancers can ramp traffic to it gradually. In AWS ALB, slow_start.duration_seconds sends a newly registered target "a linearly increasing share of the traffic"; the range is 30 to 900 seconds and the default is 0 (disabled) 4(https://docs.aws.amazon.com/elasticloadbalancing/latest/application/load-balancer-target-groups.html). NGINX Plus has a slow_start server parameter (for example slow_start=30s) whose default of 0 also disables it 2(https://docs.nginx.com/nginx/admin-guide/load-balancer/http-load-balancer/). HAProxy's dynamic algorithms, roundrobin and leastconn, allow weights to be "adjusted on the fly for slow starts" 3(https://docs.haproxy.org/3.0/configuration.html).

4. Least connections and least outstanding requests

4.1 The idea

Least connections sends new work to the server currently handling the fewest connections. It adapts automatically to requests of different lengths: a server stuck on a slow request has more open connections and receives less new work. HAProxy's leastconn sends each connection to "the server with the lowest number of connections," doing round robin among servers with equal load, and it also counts queued connections "in order to minimize queuing" 3(https://docs.haproxy.org/3.0/configuration.html). NGINX enables it with least_conn; 2(https://docs.nginx.com/nginx/admin-guide/load-balancer/http-load-balancer/). AWS ALB's version is called least_outstanding_requests 4(https://docs.aws.amazon.com/elasticloadbalancing/latest/application/load-balancer-target-groups.html). Kubernetes' IPVS mode offered lc (Least Connection) and wlc (Weighted Least Connection), although the documentation notes that IPVS mode "is deprecated since Kubernetes v1.35" 6(https://kubernetes.io/docs/reference/networking/virtual-ips/).

4.2 When HAProxy recommends it, and when not

HAProxy's manual makes a specific recommendation: leastconn is "recommended where very long sessions are expected, such as LDAP, SQL, TSE, etc... but is not very well suited for protocols using short sessions such as HTTP" 3(https://docs.haproxy.org/3.0/configuration.html). The reason is that with very short requests, connection counts are almost always near zero everywhere, so the counts carry little information.

4.3 The "sinkhole" failure

Least-loaded policies have a dangerous failure mode. A broken server that returns errors immediately finishes its requests fast, so it always looks lightly loaded, and the balancer sends it more and more traffic. Google's SRE book calls this sinkholing; the fix it describes is to count recent errors as if they were active requests 10(https://sre.google/sre-book/load-balancing-datacenter/).

The same chapter lists two further limits. Active request count is a weak proxy for actual capacity, since many requests are waiting on the network rather than using the CPU. And with client-side balancing, each client sees only its own requests, not the server's total load. As a result, the most loaded task under their least-loaded round robin could use "twice as much CPU as the least loaded," about as poorly as plain round robin 10(https://sre.google/sre-book/load-balancing-datacenter/).

Editorial suggestion: if you use a least-connections policy, make sure failing servers are removed by health checks or outlier detection quickly, or errors will attract traffic.

5. Random choice and the power of two choices

5.1 Plain random

Picking a server at random sounds naive, but it needs no shared state, which matters when many independent balancers or clients make choices. Kubernetes' iptables mode selects a backend Pod at random by default 6(https://kubernetes.io/docs/reference/networking/virtual-ips/). Envoy's documentation notes that its random balancer generally performs better than round robin when no health checking is configured 5(https://www.envoyproxy.io/docs/envoy/latest/intro/arch_overview/upstream/load_balancing/load_balancers).

5.2 The power of two choices

A small change makes random selection much better: pick two servers at random and send the request to the less loaded of the two. Michael Mitzenmacher analyzed this in "The Power of Two Choices in Randomized Load Balancing" (IEEE Transactions on Parallel and Distributed Systems, 2001) 8(https://www.eecs.harvard.edu/~michaelm/postscripts/tpds2001.pdf).

He studied a "supermarket model": customers arrive at n servers, each customer picks d servers at random and joins the one with the fewest customers. The result he describes as "surprising": having two choices "leads to exponential improvements in the expected time a customer spends in the system" compared with one choice, "whereas having d = 3 choices is only a constant factor better than d = 2" 8(https://www.eecs.harvard.edu/~michaelm/postscripts/tpds2001.pdf).

The practical lesson is that most of the benefit of comparing load comes from comparing just two options. Checking every server is unnecessary.

5.3 How real systems use it

  • Envoy: with equal weights, the weighted least request balancer picks N random hosts and chooses the one with the fewest active requests, which the documentation calls "P2C (power of two choices)"; the default choice count is 2 5(https://www.envoyproxy.io/docs/envoy/latest/intro/arch_overview/upstream/load_balancing/load_balancers).
  • HAProxy: the random algorithm takes an optional number of draws. The manual explains that "picking the least loaded of two servers is enough to significantly improve the fairness of the algorithm, by always avoiding to pick the most loaded server within a farm" 3(https://docs.haproxy.org/3.0/configuration.html). It adds that random balancing "can be useful with large farms or when servers are frequently added or removed as it may avoid the hammering effect that could result from roundrobin or leastconn in this situation" 3(https://docs.haproxy.org/3.0/configuration.html).
  • NGINX: the random method can take two and a load metric, as in random two least_time=last_byte; 2(https://docs.nginx.com/nginx/admin-guide/load-balancer/http-load-balancer/).

5.4 Why not just pick the least-loaded server?

Dean and Barroso's "The Tail at Scale" (2013) explains the problem with probing every server and choosing the least loaded. They list three reasons it is less effective than it sounds: "load levels can change between probe and request time; request service times can be difficult to estimate"; and "clients can create temporary hot spots by all clients picking the same (least-loaded) server at the same time" 11(https://www.barroso.org/publications/TheTailAtScale.pdf). Random choice between two avoids the herd effect, because different clients pick different pairs.

6. Hashing: sending the same key to the same server

6.1 Why hash

Sometimes you want the same request to land on the same server: so a cache on that server is reused, or so a user's session data is found. Hash-based balancing computes a hash of some request property (client IP address, URL, a header or cookie) and maps it to a server.

HAProxy offers several: source hashes the client IP; uri hashes the URI and "is used with proxy caches and anti-virus proxies in order to maximize the cache hit rate"; url_param hashes a query parameter, useful to "track user identifiers"; and a general hash takes any expression 3(https://docs.haproxy.org/3.0/configuration.html). NGINX has ip_hash and a generic hash, for example hash $request_uri consistent; 2(https://docs.nginx.com/nginx/admin-guide/load-balancer/http-load-balancer/).

6.2 The problem with simple hashing

A simple hash divides the hash by the number of servers. HAProxy's manual spells out the consequence for source: the same client goes to the same server "as long as no server goes down or up. If the hash result changes due to the number of running servers changing, many clients will be directed to a different server" 3(https://docs.haproxy.org/3.0/configuration.html). For a cache cluster, that means most of the cache is effectively lost every time a server is added or removed.

6.3 Consistent hashing

Consistent hashing fixes this. The technique was introduced by David Karger and colleagues in "Consistent hashing and random trees," presented at the ACM Symposium on Theory of Computing in 1997 9(https://doi.org/10.1145/258533.258660) (bibliographic record only). The common form places servers on a ring at many points; each key goes to the next server around the ring.

Envoy's ring hash balancer works this way: hosts are hashed onto a ring and each request goes to the nearest host clockwise from its hashed key 5(https://www.envoyproxy.io/docs/envoy/latest/intro/arch_overview/upstream/load_balancing/load_balancers). HAProxy's hash-type consistent uses "a tree filled with many occurrences of each server"; the manual explains that "when a server goes up or down, only its associations are moved," which makes it "an ideal method for caches" 3(https://docs.haproxy.org/3.0/configuration.html). NGINX's consistent parameter enables "ketama" consistent hashing 2(https://docs.nginx.com/nginx/admin-guide/load-balancer/http-load-balancer/).

The trade-off is evenness. HAProxy warns that "the distribution will never be very smooth and it may sometimes be necessary to adjust a server's weight or its ID to get a more balanced distribution" 3(https://docs.haproxy.org/3.0/configuration.html).

6.4 Maglev hashing

Google designed a different consistent hashing scheme for Maglev because it needed a different balance of goals. The paper names two properties: "load balancing: each backend will receive an almost equal number of connections" and "minimal disruption: when the set of backends changes, a connection will likely be sent to the same backend as it was before" 7(https://storage.googleapis.com/gweb-research2023-media/pubtools/2904.pdf).

Earlier schemes "prioritize minimal disruption over load balancing, as they were designed to optimize web caching on a small number of servers," the authors write; Maglev "takes the opposite approach" because uneven load would force backends to be "aggressively overprovisioned in order to accommodate the peak traffic" 7(https://storage.googleapis.com/gweb-research2023-media/pubtools/2904.pdf).

Envoy implements Maglev hashing with a fixed lookup table of 65,537 entries and compares it with ring hash 5(https://www.envoyproxy.io/docs/envoy/latest/intro/arch_overview/upstream/load_balancing/load_balancers):

  • Speed: Maglev builds its table roughly 10 times faster and selects hosts about 5 times faster than ring hash with a 256K ring.
  • Stability: ring hash is more stable when hosts change; removing hosts moves about twice as many keys under Maglev.
  • Distribution caveat: when the number of hosts exceeds the table size, some hosts get no entries regardless of weight.

Kubernetes' IPVS mode also offered mh (Maglev Hashing) as a scheduler 6(https://kubernetes.io/docs/reference/networking/virtual-ips/).

6.5 Connection tracking plus hashing

Maglev uses hashing together with connection tracking: a table remembering which backend each existing connection was sent to. Neither alone is enough. The paper explains that the routers in front of Maglev do not keep connection affinity, so when the set of Maglev machines changes (during a rolling upgrade that "may last over an hour," for example), packets of an existing connection can arrive at a different Maglev machine that has no record of it 7(https://storage.googleapis.com/gweb-research2023-media/pubtools/2904.pdf). The connection table also has finite space and can fill "under heavy load or SYN flood attacks" 7(https://storage.googleapis.com/gweb-research2023-media/pubtools/2904.pdf). Consistent hashing ensures that even without the table, most connections still reach the same backend.

7. Health checks, failover and draining

7.1 Active and passive checks

A balancer must stop sending traffic to dead servers. There are two broad ways to find out:

  • Active health checks: the balancer periodically sends a probe (a TCP connection, an HTTP request to a health endpoint).
  • Passive health checks: the balancer watches real traffic and marks a server down after failures.

HAProxy's active checks are configured per server. By default, the interval between checks is 2,000 milliseconds (inter), a server is considered operational after 2 consecutive successful checks (rise) and dead after 3 consecutive failures (fall) 3(https://docs.haproxy.org/3.0/configuration.html). NGINX's open-source version provides passive checks through the max_fails and fail_timeout server parameters, and active health checks require the shared-memory zone directive 2(https://docs.nginx.com/nginx/admin-guide/load-balancer/http-load-balancer/).

Hypothetical example: with HAProxy's defaults, a server that dies stops receiving traffic after three failed checks, so roughly six seconds plus probe timeouts. During that window, some requests reach the dead server. That is one reason retries and passive detection are used alongside active checks.

7.2 What happens when too many servers fail

Removing unhealthy servers can backfire if most of the pool is unhealthy: the remaining few healthy servers get all the load and may fall over too. AWS ALB handles this with explicit thresholds 4(https://docs.aws.amazon.com/elasticloadbalancing/latest/application/load-balancer-target-groups.html):

  • By default, "a target group is considered healthy as long as it has at least one healthy target."
  • DNS failover: when healthy targets in a zone fall below a threshold, that zone's load balancer addresses are marked unhealthy in DNS, so new clients go to healthy zones.
  • Routing failover: when healthy targets fall below a threshold, the load balancer "sends traffic to all targets... including unhealthy targets." AWS explains this "reduces the risk of overloading the healthy targets."
  • If all zones are unhealthy, the load balancer sends traffic to all zones anyway.

This "fail open" behavior is a deliberate trade-off. If health checks are wrong (for example, because the health endpoint depends on a shared database that is briefly slow), refusing to send traffic anywhere would turn a partial problem into a complete outage.

AWS's documentation works through an example. With two zones of 10 targets each, 50% thresholds and six failures in zone B: if cross-zone balancing is off, zone B has only 40% healthy targets and fails over; if cross-zone balancing is on, the pool as a whole has 14 of 20 targets healthy, 70%, and traffic simply goes to those 14 4(https://docs.aws.amazon.com/elasticloadbalancing/latest/application/load-balancer-target-groups.html).

7.3 Outlier detection

Health checks test a special endpoint. A server can pass them while failing real requests. Envoy and similar proxies add outlier detection, ejecting hosts that produce too many errors on real traffic. The SRE book's sinkhole example (section 4.3) shows why this matters most for least-loaded policies 10(https://sre.google/sre-book/load-balancing-datacenter/).

7.4 Draining and lame duck mode

Taking a server out cleanly is as important as detecting a failure. AWS ALB stops routing new requests to a deregistered target immediately; the target enters a draining state "until in-flight requests have completed," with a default deregistration delay of 300 seconds (range 0 to 3,600) 4(https://docs.aws.amazon.com/elasticloadbalancing/latest/application/load-balancer-target-groups.html).

Google's SRE book describes a lame duck state in which a backend can still serve but "is explicitly asking clients to stop sending requests," allowing in-flight requests to finish without errors 10(https://sre.google/sre-book/load-balancing-datacenter/). The chapter suggests a drain window of 10 to 150 seconds and says lame-duck status typically reaches clients within one or two round trips 10(https://sre.google/sre-book/load-balancing-datacenter/).

8. Session persistence (sticky sessions)

8.1 Methods

Some applications keep per-user state in a server's memory. Sticky sessions send a returning user to the same server. Common methods, as documented:

  • Load-balancer cookie. AWS ALB's lb_cookie stickiness has a default duration of one day (86,400 seconds), maximum seven days 4(https://docs.aws.amazon.com/elasticloadbalancing/latest/application/load-balancer-target-groups.html). NGINX Plus supports sticky cookie, for example sticky cookie srv_id expires=1h domain=.example.com path=/; 2(https://docs.nginx.com/nginx/admin-guide/load-balancer/http-load-balancer/).
  • Application cookie. ALB's app_cookie uses a cookie the application sets; certain names starting with AWSALB are reserved 4(https://docs.aws.amazon.com/elasticloadbalancing/latest/application/load-balancer-target-groups.html).
  • Client IP. Kubernetes Services support sessionAffinity: ClientIP (the default is None), with a default stickiness timeout of 10,800 seconds, "which works out to be 3 hours" 6(https://kubernetes.io/docs/reference/networking/virtual-ips/). In open-source NGINX, session persistence is achieved with hash or ip_hash 2(https://docs.nginx.com/nginx/admin-guide/load-balancer/http-load-balancer/).

Stickiness is off by default in AWS ALB (stickiness.enabled defaults to false) 4(https://docs.aws.amazon.com/elasticloadbalancing/latest/application/load-balancer-target-groups.html).

8.2 Costs of stickiness

Editorial suggestion: stickiness works against balancing. It pins users to servers, so a few heavy users can overload one server while others sit idle. When a server fails, its sticky users lose their state anyway. Client-IP affinity can also put many users behind one corporate or mobile network gateway on a single server. Where possible, store session state outside the web servers (in a shared database or cache), which makes stickiness unnecessary.

HAProxy's manual notes that a balancing algorithm "only applies when no persistence information is available" 3(https://docs.haproxy.org/3.0/configuration.html); in other words, stickiness overrides the algorithm.

9. Tail latency: why balancing gets harder at scale

9.1 Fan-out amplifies rare slowness

Many large services handle one user request by querying many backend servers in parallel and combining the results. Dean and Barroso show why this makes rare slow responses common. They consider "a system where each server typically responds in 10ms but with a 99th-percentile latency of one second." With one server, one request in 100 is slow. But "if a user request must collect responses from 100 such servers in parallel, then 63% of user requests will take more than one second" 11(https://www.barroso.org/publications/TheTailAtScale.pdf). Even if only one request in 10,000 is slow on a single server, a service using 2,000 such servers in parallel "will see almost one in five user requests taking more than one second" 11(https://www.barroso.org/publications/TheTailAtScale.pdf).

The arithmetic: the chance all 100 responses are fast is 0.99 to the power 100, about 0.37, so about 63% of user requests include at least one slow response.

9.2 Hedged and tied requests

No balancing algorithm can predict every slow response, so Dean and Barroso describe techniques that tolerate them:

  • Hedged requests. Send the request to one replica; if it has not answered after a short delay, send a second copy to another replica and use whichever answers first. Deferring the hedge until the first request has been outstanding longer than the 95th-percentile expected latency "limits the additional load to approximately 5% while substantially shortening the latency tail" 11(https://www.barroso.org/publications/TheTailAtScale.pdf).
  • Observed result: in a Google benchmark reading 1,000 keys from a BigTable table spread across 100 servers, "sending a hedging request after a 10ms delay reduces the 99.9th-percentile latency for retrieving all 1,000 values from 1,800ms to 74ms while sending just 2% more requests" 11(https://www.barroso.org/publications/TheTailAtScale.pdf).
  • Tied requests. Enqueue copies on multiple servers at once, and let the servers tell each other when one starts work so the others can cancel 11(https://www.barroso.org/publications/TheTailAtScale.pdf).

These techniques sit alongside the balancer, not inside it. Their existence is a reminder that load balancing is one part of keeping latency low, not the whole of it.

10. Large fleets: subsetting

When thousands of clients each connect to thousands of backends, the connections themselves become a cost; each uses memory and CPU at both ends. Google's SRE book describes subsetting: each client connects only to a subset of backends, typically 20 to 100 10(https://sre.google/sre-book/load-balancing-datacenter/).

How subsets are chosen matters. The chapter reports that with 300 clients and 300 backends, random subsets of 30% left backend load ranging from 63% to 121% of average; with 10% subsets the range was 50% to 150% 10(https://sre.google/sre-book/load-balancing-datacenter/). Their solution, deterministic subsetting, shuffles the backend list for each "round" of clients so that each backend is assigned to about one client per round, keeping connection counts within one of each other in most cases 10(https://sre.google/sre-book/load-balancing-datacenter/).

11. Choosing an approach

11.1 A decision guide

Editorial suggestion, drawn from the documentation and papers above:

SituationReasonable starting pointWhy
Identical servers, short similar HTTP requestsRound robinSimple and fair when processing time is evenly distributed 3(https://docs.haproxy.org/3.0/configuration.html)
Servers of different sizesWeighted round robinWeights reflect capacity 2(https://docs.nginx.com/nginx/admin-guide/load-balancer/http-load-balancer/)
Long-lived sessions (databases, LDAP, remote desktop)Least connectionsHAProxy's recommended use case 3(https://docs.haproxy.org/3.0/configuration.html)
Variable request cost, many balancers or clientsPower of two choicesAvoids herding; most of the benefit of comparing load 8(https://www.eecs.harvard.edu/~michaelm/postscripts/tpds2001.pdf), 5(https://www.envoyproxy.io/docs/envoy/latest/intro/arch_overview/upstream/load_balancing/load_balancers)
Caches, sharded dataConsistent hashing (ring or Maglev)Keeps keys on the same server when the pool changes 3(https://docs.haproxy.org/3.0/configuration.html), 7(https://storage.googleapis.com/gweb-research2023-media/pubtools/2904.pdf)
Very high packet rates at the network edgeLayer-4 balancer with ECMP and consistent hashingThe Maglev design 7(https://storage.googleapis.com/gweb-research2023-media/pubtools/2904.pdf)

11.2 Checklist before going to production

  1. Know your request mix. Are request costs similar, or do some take 1,000 times longer? The SRE book reports cost differences of that order in practice 10(https://sre.google/sre-book/load-balancing-datacenter/).
  2. Configure health checks deliberately. Know the interval and failure count (HAProxy defaults: 2 s, 2 to rise, 3 to fall) 3(https://docs.haproxy.org/3.0/configuration.html).
  3. Plan for mass failure. Decide whether to fail open when most targets look unhealthy, as AWS ALB does 4(https://docs.aws.amazon.com/elasticloadbalancing/latest/application/load-balancer-target-groups.html).
  4. Guard against sinkholes. Count errors as load or eject erroring hosts 10(https://sre.google/sre-book/load-balancing-datacenter/).
  5. Drain before removing. Use deregistration delay or a lame-duck state 4(https://docs.aws.amazon.com/elasticloadbalancing/latest/application/load-balancer-target-groups.html), 10(https://sre.google/sre-book/load-balancing-datacenter/).
  6. Warm up new servers with slow start if they need it 4(https://docs.aws.amazon.com/elasticloadbalancing/latest/application/load-balancer-target-groups.html).
  7. Avoid stickiness unless the application truly needs it.
  8. Watch the tail, not just the average: measure 99th and 99.9th percentile latency 11(https://www.barroso.org/publications/TheTailAtScale.pdf).
  9. Remember DNS caching if any layer relies on DNS 1(https://www.rfc-editor.org/rfc/rfc1794).
  10. Pin the mode explicitly in systems whose defaults may change, such as Kubernetes kube-proxy, which recommends setting the proxy mode explicitly so it doesn't change unexpectedly during an upgrade 6(https://kubernetes.io/docs/reference/networking/virtual-ips/).

11.3 A worked example

Hypothetical example. A team runs an image-resizing API on eight identical servers. Most requests take 20 ms, but a few large images take 3 seconds. They start with round robin. Under load, they see occasional spikes: a server that receives two or three large images in a row builds a queue, and round robin keeps sending it its share of new requests.

Switching to least connections would help in principle, but with mostly short HTTP requests, HAProxy's guidance suggests connection counts carry little signal 3(https://docs.haproxy.org/3.0/configuration.html). A power-of-two-choices policy (HAProxy random(2) or Envoy least request) is a better fit: each request compares two servers' current load, and the busy server is avoided when it is one of the pair 5(https://www.envoyproxy.io/docs/envoy/latest/intro/arch_overview/upstream/load_balancing/load_balancers), 3(https://docs.haproxy.org/3.0/configuration.html). They also add outlier detection so a server that starts failing fast does not become a sinkhole 10(https://sre.google/sre-book/load-balancing-datacenter/). Their measurement of success should be 99th-percentile latency, not the average.

12. Frequently asked questions

What is the default algorithm in common load balancers? Round robin, in open-source NGINX 2(https://docs.nginx.com/nginx/admin-guide/load-balancer/http-load-balancer/) and in AWS ALB target groups 4(https://docs.aws.amazon.com/elasticloadbalancing/latest/application/load-balancer-target-groups.html). Kubernetes' default iptables mode selects backends at random 6(https://kubernetes.io/docs/reference/networking/virtual-ips/).

Is least connections always better than round robin? No. HAProxy recommends it for long sessions and says it is "not very well suited" for short-session protocols like HTTP 3(https://docs.haproxy.org/3.0/configuration.html). Google found its least-loaded round robin performed about as poorly as plain round robin in its environment 10(https://sre.google/sre-book/load-balancing-datacenter/).

What is "power of two choices"? Pick two servers at random and use the less loaded one. Mitzenmacher showed two choices give exponential improvement over one, while a third adds only a constant factor 8(https://www.eecs.harvard.edu/~michaelm/postscripts/tpds2001.pdf).

Why use consistent hashing? So that adding or removing a server moves only a small share of keys, instead of reshuffling almost everything, which matters for caches 3(https://docs.haproxy.org/3.0/configuration.html).

What's the difference between Maglev and ring hash? In Envoy's implementation, Maglev is faster to build and look up; ring hash is more stable when hosts change 5(https://www.envoyproxy.io/docs/envoy/latest/intro/arch_overview/upstream/load_balancing/load_balancers).

Can DNS alone do load balancing? It can distribute clients, but caching means it reacts slowly to failures, a limitation documented as far back as RFC 1794 1(https://www.rfc-editor.org/rfc/rfc1794).

Why would a load balancer send traffic to unhealthy servers? To avoid overloading the few remaining healthy ones when health checks report most of the pool as down; AWS ALB does this when healthy targets fall below a threshold 4(https://docs.aws.amazon.com/elasticloadbalancing/latest/application/load-balancer-target-groups.html).

Do I need sticky sessions? Only if your application stores per-user state on individual servers. Moving that state to shared storage usually gives better balancing and resilience.

13. Bottom line

  • Round robin is the common default and is fair when requests and servers are uniform; it can leave a 2x CPU spread when they are not 10(https://sre.google/sre-book/load-balancing-datacenter/).
  • Weights handle known capacity differences; feedback-based weights handle unknown ones 10(https://sre.google/sre-book/load-balancing-datacenter/), 5(https://www.envoyproxy.io/docs/envoy/latest/intro/arch_overview/upstream/load_balancing/load_balancers).
  • Least connections suits long sessions, but beware sinkholing by fast-failing servers 3(https://docs.haproxy.org/3.0/configuration.html), 10(https://sre.google/sre-book/load-balancing-datacenter/).
  • Choosing the better of two random servers captures most of the benefit of load-aware balancing without herding 8(https://www.eecs.harvard.edu/~michaelm/postscripts/tpds2001.pdf), 11(https://www.barroso.org/publications/TheTailAtScale.pdf).
  • Consistent hashing (ring or Maglev) keeps keys stable as servers change 7(https://storage.googleapis.com/gweb-research2023-media/pubtools/2904.pdf).
  • Health checks, fail-open thresholds and draining matter as much as the algorithm 4(https://docs.aws.amazon.com/elasticloadbalancing/latest/application/load-balancer-target-groups.html).
  • At scale, tail latency dominates; hedged requests can cut it sharply for a small amount of extra load 11(https://www.barroso.org/publications/TheTailAtScale.pdf).

Sources

Last checked: 2026-11-27

  • [1] Brisco, T. (1995). RFC 1794, "DNS Support for Load Balancing." Informational. RFC Editor. https://www.rfc-editor.org/rfc/rfc1794
  • [2] F5 / NGINX. "HTTP Load Balancing." NGINX Admin Guide. Accessed 2026. https://docs.nginx.com/nginx/admin-guide/load-balancer/http-load-balancer/
  • [3] HAProxy Technologies / HAProxy project. "HAProxy Configuration Manual," version 3.0 (sections on balance, hash-type, inter, rise, fall; read from the project's configuration.txt source). https://docs.haproxy.org/3.0/configuration.html
  • [4] Amazon Web Services. "Target groups for your Application Load Balancers." Elastic Load Balancing User Guide. Accessed 2026. https://docs.aws.amazon.com/elasticloadbalancing/latest/application/load-balancer-target-groups.html
  • [5] Envoy Project. "Supported load balancers." Envoy documentation (latest). Accessed 2026. https://www.envoyproxy.io/docs/envoy/latest/intro/arch_overview/upstream/load_balancing/load_balancers
  • [6] The Kubernetes Authors. "Virtual IPs and Service Proxies." Kubernetes documentation. Accessed 2026. https://kubernetes.io/docs/reference/networking/virtual-ips/
  • [7] Eisenbud, D. E., Yi, C., Contavalli, C., Smith, C., Kononov, R., Mann-Hielscher, E., Cilingiroglu, A., Cheyney, B., Shang, W., & Hosein, J. D. (2016). "Maglev: A Fast and Reliable Software Network Load Balancer." NSDI '16, USENIX. Publication page and full PDF: https://research.google/pubs/maglev-a-fast-and-reliable-software-network-load-balancer/ and https://storage.googleapis.com/gweb-research2023-media/pubtools/2904.pdf
  • [8] Mitzenmacher, M. (2001). "The Power of Two Choices in Randomized Load Balancing." IEEE Transactions on Parallel and Distributed Systems 12(10). Author's PDF. https://www.eecs.harvard.edu/~michaelm/postscripts/tpds2001.pdf
  • [9] Karger, D., Lehman, E., Leighton, T., Panigrahy, R., Levine, M., & Lewin, D. (1997). "Consistent hashing and random trees." Proceedings of STOC '97, ACM (bibliographic record only). https://doi.org/10.1145/258533.258660
  • [10] Forero Cuervo, A. (ed. Chavis, S.). "Load Balancing in the Datacenter." Chapter 20 in Site Reliability Engineering, Google / O'Reilly, 2016; online edition. https://sre.google/sre-book/load-balancing-datacenter/
  • [11] Dean, J., & Barroso, L. A. (2013). "The Tail at Scale." Communications of the ACM 56(2). Author-hosted PDF. https://www.barroso.org/publications/TheTailAtScale.pdf

This page was researched and written by an AI assistant for Apiary from an unsourced local draft. Sources were opened and read on 27 November 2026. It has not been reviewed by a human expert. Status: candidate.

Frequently asked
What is Load Balancing Techniques: Algorithms, Health Checks and Trade-offs about?
A load balancer sits between clients and a pool of servers (often called backends, upstreams, targets or endpoints) and spreads requests or connections across…
What should you know about 1.1 DNS-based distribution?
The oldest form of load balancing on the internet returns different server addresses for the same name. RFC 1794, "DNS Support for Load Balancing," written by Thomas Brisco of Rutgers University in April 1995, describes one such approach 1 (https://www.rfc-editor.org/rfc/rfc1794). It is an Informational RFC that, in…
What should you know about 1.2 Network (layer 4) load balancing?
A layer-4 balancer sees IP addresses and ports, not HTTP requests. It must send every packet of a TCP connection to the same backend. Google's Maglev, described in a 2016 NSDI paper, is a well-documented example 7 (https://research.google/pubs/maglev-a-fast-and-reliable-software-network-load-balancer/). It is a…
What should you know about 1.3 Application (layer 7) load balancing?
A layer-7 balancer understands the application protocol, usually HTTP. It can route by path, header or cookie, retry failed requests, and balance per request rather than per connection. NGINX, HAProxy, Envoy and AWS's Application Load Balancer all work at this layer, and their documented algorithms are the core of…
What should you know about 1.4 Client-side and in-cluster balancing?
Sometimes there is no separate balancer: each client picks a backend itself. Google's Site Reliability Engineering book describes this design for traffic inside a datacenter, where clients keep long-lived connections to backends and choose among them 10 (https://sre.google/sre-book/load-balancing-datacenter/). Envoy…
References & sources
  1. Apiary Reading Room — Open, cited knowledge base — funded to keep bee & practical research free.
From the Apiary Reading Room. Opinion & editorial — not financial advice. We don't overclaim.
More from the Reading Room