The load balancer times every answer and keeps a moving average for each server. Each new request goes to the server with the lowest average response time, counting the requests it already has in progress. It measures speed directly, where least connections only infers it. Below, compare it with least connections and round robin on the same traffic.
Each server drawn stands for one of your servers, and each dot for 100 real requests. Only the speed is slowed, so you can follow single requests. Least response time scores each server as its average response time x (its requests in progress + 1) and picks the lowest. 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, slow requests and a failed server. 50 to 70% is common.
1. Average requests per second
2. Peak requests per second
3. Servers needed n
4. Load on each server
5. One server half as fast
6. About one request in five taking 4x as long
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 spreads the same traffic over n - 1 full servers and one half server.
NGINX calls it least time, and lets you choose which part of the response to time.
least_time, "a request is passed to the server with the least average response time and least number of active connections, taking into account weights of servers." Ties are "tried in turn using a weighted round-robin balancing method", the same rule used in the scene. NGINX does not document exactly how the two measures are combined or averaged; the score in the scene is one common way to do it.least_time header uses the time to receive the response header, and least_time last_byte the time to receive the full response; adding inflight also counts requests still in progress. The documentation notes that before version 1.31.0 the method was available only as part of NGINX's commercial subscription.Both are NGINX's own documentation (primary sources). Quoted phrases are short attributed quotations; everything else is described in our words. Availability changes between versions, so check the pages for your version.