Haproxy Cookies Configuration for Multiple backend server

Hello,

Can anyone guide me to configure cookies in below scenario…!

My backend servers are configured with AWS Autoscaling Group, so I’m going to add and remove backend server to/from Haproxy configuration based on CPU metrics. So during this, I want to configure centralized cookies so that the end user can continue to access the site without leaving even if any server is removed from the backend.

Thanks in advance.

Can you help me understand your intended workflow? So let’s say a pool member is to be removed. Would you then edit the configuration and remove the pool member from the actual backend directive and reload the configuration?

The main idea that comes to mind for me would be to use “force persist” and just use a monitor to mark the backend server as down then wait for the sticky connections to bleed off.

https://www.haproxy.com/documentation/haproxy-configuration-manual/latest/#4.2-force-persist

Does that do what you’re looking for?