DOC: config: prefer-last-server: add notes for non-deterministic algorithms
authorValentine Krasnobaeva <vkrasnobaeva@haproxy.com>
Tue, 17 Jun 2025 13:33:12 +0000 (13:33 +0000)
committerChristopher Faulet <cfaulet@haproxy.com>
Tue, 26 Aug 2025 06:24:14 +0000 (08:24 +0200)
Add some notes which load-balancing algorithm can be considered as
deterministic or non-deterministic and add some examples for each type.
This was asked via mailing list to clarify the usage of
prefer-last-server option.

This can be backported to all stable versions.

(cherry picked from commit cdb2f8d780a27778cc23669693a9910e07135e8a)
Signed-off-by: Willy Tarreau <w@1wt.eu>
(cherry picked from commit d6ca14b764039ed1c5d21d2fa83706996fd0a717)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>

doc/configuration.txt

index 88dd479..aebc8d4 100644 (file)
@@ -10813,8 +10813,23 @@ no option prefer-last-server
   desirable in these environments as well, to avoid redistributing the traffic
   after every other response.
 
-  If this option has been enabled in a "defaults" section, it can be disabled
-  in a specific instance by prepending the "no" keyword before it.
+  It may be useful to precise here, which load balancing algorithms are
+  considered deterministic. Deterministic algorithms will always select the same
+  server for a given client data, assuming the set of available servers has not
+  changed. In general, deterministic algorithms involve hasing or lookups on the
+  incoming requests to choose the target server. However, this is not always the
+  case; "static-rr", for example, can be also considered as deterministic because
+  the server choice is based on the server's static weight, making the selection
+  predictable. "sticky" algorithm provides deterministic routing for the
+  returning clients.
+
+  As for non-deterministic algorithms, these algorithms select a server based on
+  dynamic server state or simple rotation, so two consecutive requests are not
+  guaranteed to land on the same server. option prefer-last-server is designed
+  specifically for these. roundrobin, leastconn are examples of such algorithms.
+
+  If this option has been enabled in a "defaults" section, it can be
+  disabled in a specific instance by prepending the "no" keyword before it.
 
   See also: "option http-keep-alive"