An agent on each server reports how busy the machine is, here its CPU use, every few seconds, and the load balancer sends work according to those reports. It is the only method that sees load the balancer did not cause itself. Below, compare two ways of using the reports with round robin, on the same traffic.
Each server drawn stands for one of your servers, and each dot for 100 real requests. "Busy" on each server is its share of time serving requests; a CPU report also includes any background work. Switching the algorithm restarts the run with exactly the same requests.
Busiest hour vs the daily average. The book's estimate uses 2x.
Measured by load testing one server until it cannot go faster.
Headroom for spikes and for background work. 50 to 70% is common.
1. Average requests per second
2. Peak requests per second
3. Servers needed n
4. Load on each server, on average
5. One server losing 50% of its CPU to other work
6. Reports every 2 s
Steps 1 and 2 are the estimation method from the back-of-the-envelope chapter of Alex Xu's System Design Interview, Vol. 1, including its 2x peak. The rest is standard capacity planning. The second line of step 5 is the best case, the traffic spread over n - 0.5 servers' worth of free CPU; reports that lag behind keep it from getting all the way there.
Both turn the reports into weights rather than picking a single winner.
50% "Changes the server's weight to a percentage of its current value"; drain stops new connections and down takes the server out. HAProxy's own example agent replies 50% when the server is short of idle CPU time, which is the idea on this page.weighted_round_robin policy "requires direct load reporting from backends to clients" and computes each backend's weight as qps / (utilization + ...), using CPU utilization unless the server reports its own measure. It waits a 10 second "blackout period" before trusting a new backend's reports, stops using a weight that has not been reported for 3 minutes, and falls back to plain round robin when fewer than two backends report.Both are primary sources: HAProxy's own documentation, and gRPC's design proposal for the policy (gRFC A58, marked implemented in C-core, Java and Go). Quoted phrases are short attributed quotations; everything else is described in our words. Defaults can change between versions, so check the pages.