Adding Session Persistence for HAProxy
HAProxy provides a multitude of load balancing algorithms, some of which provide features
that automatically ensure that web sessions have persistent connections to the same backend
server. You can configure a balance algorithm such as hdr,
rdp-cookie, source, uri, or
url_param to ensure that traffic is always routed to the same web server
for a particular incoming connection during the session. For example, the
source algorithm creates a hash of the source IP address and maps it to a
particular backend server. If you use the rdp-cookie, or
url_param algorithms, you might need to configure the backend web servers
or the web applications for these mechanisms to run efficiently.
If the implementation requires the use of the leastconn,
roundrobin, or static-rr algorithm, you can achieve
session persistence by using server-dependent cookies.