HAProxy Enterprise Documentation 2.1r1
Session persistence means that HAProxy Enterprise routes a client to the same backend server once they have been routed to that server once. It avoids the overhead of re-establishing a client's state on a new server with each request, since the same server is always chosen. Often, it is optimal to avoid session persistence altogether by building your services to be stateless, such as by storing state off of the application servers in a shared database. However, for certain applications this is not possible.
HAProxy Enterprise supports two forms of session persistence:
To enable session persistence based on the client's IP address:
stick-table line to your
backend section. It creates an in-memory storage to hold client IP addresses. Entries in the stick table expire after 30 minutes if they are not used.
Add the line
stick on src, which stores a client's IP address in the stick table and associate it with the server to which they were routed. On subsequent visits, they will use this same server.
stick-table type ip size 1m expire 30m
stick on src
server s1 192.168.0.10:80 check
server s2 192.168.0.11:80 check
Next up Traffic Routing