@kr428 wrote:
Folks,
we just introduced haproxy to replace apache2 providing reverse proxy / load balancing across a couple of tomcat servers hosting the same application, and we need persistent sessions for users. So far, however, even though anything else works way faster in regular operations, we more often see users complaining about the application complaining about "lost sessions", which is caused by the request being routed to the "wrong" backend. Usually this happens as soon as we brought down and restarted one of the instances. I am not really sure what's causing this trouble so far but noticed one weirdness in cookies.
Currently our backend looks similar to this:
backend app balance leastconn mode http cookie JSESSIONID prefix indirect nocache server srv16060 localhost:16060 cookie srv16060 check maxconn 1000 server srv17070 localhost:17070 cookie srv17070 check maxconn 1000
I omitted a bunch of server lines as they all basically look the same. I see, by now, cookies like these added to the request:
"srv16060~srv160601j3jy5h4ptzerl68anyg1rn8z.srv16060"
This, however, is the session cookie already provided by the backend system itself, thanks to tomcat / jvmRoute configuration.
"srv160601j3jy5h4ptzerl68anyg1rn8z.srv16060"
The name of the instance (srv16060) in this case always is suffixed to the cookie. Unsure whether this is actually a problem, but: Ain't there a way to set up haproxy to evaluate these backend cookies and figure out which server it belongs to by information provided in the cookie itself, i.e. make sure all cookies having ".srv16060" suffix in it will go to the srv16060 server? Pardon me if this is a trivial question - looking at the "prefix" option in the cookies directive I was hoping something like this is already available out of the box but so far I failed to set it up...
TIA and all the best,
Kristian
Posts: 2
Participants: 2