Affinity and session stickiness
There are three method to setup affinity and sticky session:
- set
BALANCE=source
in your application service. When settingsource
method of balance, HAProxy will hash the client IP address and make sure that the same IP always goes to the same server. - set
APPSESSION=<value>
. use application session to determine which server a client should connect to. Possible value of<value>
could beJSESSIONID len 52 timeout 3h
- set
COOKIE=<value>
. use application cookie to determine which server a client should connect to. Possible value of<value>
could beSRV insert indirect nocache
Check HAProxy:appsession and HAProxy:cookie for more information.