HAProxy 00:00:01 Pick a backend for a checkout The checkout reaches HAProxy with one public address on the front and several application servers behind it. Trace the decisions from connection acceptance to a completed backend response. TLS ends here. The request must be complete within timeout http-request. A stick table can track recent requests for a chosen key. The example source has twelve requests against its configured allowance of two hundred in ten seconds. The path begins with /api/, so the backend is api. api2 is chosen. An idle connection is reused. One line records where the time went. Record queue time separately from time waiting for the server and time delivering the response. The same slow checkout can originate at three different places. 00:00:48 Two choices instead of a fleet scan Suppose the load-balancing policy samples two available backends and compares the observed load. It does not need the globally least loaded server for this selection to be useful. api1 is the busiest. Chance gives api1 and api3. The comparison is seven observed connections against nine. The backend with seven wins this sample without being the least loaded member of the whole fleet. Chance gives api1 and api2. api2 wins. Taking the lighter of two samples avoids many overloaded choices at low decision cost. Active connections are a proxy for work, so check whether long and short requests have comparable costs. 00:01:31 Health requires a streak A transient failure should not always expel a healthy server, and one successful probe should not always send full traffic back. Configure failure and recovery thresholds for what the service can tolerate. The check agrees with the state, so the streak is 0. A single failure changes nothing. With the intervals and fall threshold shown here, a server that first fails a check remains eligible for several seconds before it is removed. In this configuration two successful checks return the server to service. Slow start can then increase its share gradually. Thresholds trade detection speed for stability. Include the interval and timeout in the detection budget, then ramp traffic if an apparently healthy instance still has cold caches. 00:02:15 Put a time value on the queue The service can complete six thousand requests per second in this simplified peak-load example. Seven thousand arrive each second. Queuing temporarily absorbs the difference but cannot eliminate it. 4,000 a second fit easily. 7,000 a second. All places are taken, and 1,000 a second join the queue. After six seconds 6,000 wait, which is one second of work. The wait is the queue divided by 6,000. At thirty thousand waiting requests the simplified estimate is five seconds. The configured queueing limits can reject additional work. The peak ends. The queue empties and nothing has to recover. Six thousand waiting requests represent about a second of waiting at a steady six thousand completions per second. Once the wait exceeds the caller's budget, bounded admission is more honest than a growing queue. 00:03:07 When every health check asks the same database An innocent readiness check runs an expensive shared database query on every backend. That dependency slows down. Suddenly every machine appears unhealthy, including those able to serve standalone pages. All servers are up. Every check times out at the same moment. The check asks only whether this server can work. Pages without the database stay up. A useful check tests the serving contract of the backend it can remove. Monitor the shared database separately, and rehearse how the balancer behaves when all its probes fail together.