Docker Community Forums

Share and learn in the Docker community.

Docker Swarm- maintain sticky session through container restart

(tech74) #1


We have a multiservice architecture consisting of HAProxy front end , a mongodb database, and multiple instances of a backend app running under Docker Swarm.

We need to use sticky sessions to route requests to the same backend app. The backend app uses TCP sockets to communicate with a VoIP PBX. The plan is to give each instance of the backend app a ‘label’ which persists even if the instance is restarted and recreated on another machine. This label would need to be assigned when the instance was created and then persist. The plan is that the HAProxy load balancer could use the label to route to the backend instance. We plan to run the HAProxy infront of the swarm as a pair with Heartbeat and a floating IP. The main architectural issue we are stuck on is how to ensure future requests are routed to the same backend instance even if that instance is recreated elsewhere.