HAProxy appsession vs cookie precedence

Posted by user1139473 on Server Fault See other posts from Server Fault or by user1139473
Published on 2013-11-05T20:59:39Z Indexed on 2013/11/05 21:55 UTC
Read the original article Hit count: 164

Filed under:

I am trying to find the best solution for balancing and keeping persistence on our application behind HAProxy.

Here is our basic configuration: https://gist.github.com/endzyme/1804046b23c37beba520

After playing around with taking members down and up and also reloading the haproxy (with -sf) I have noticed that appsession isn't 100% effective, it would appear that sometimes it doesn't always 'request-learn'. I also tried to add a cookie JSESSION prefix to balance in case request-learn didn't take.

Unfortunately it would present scenarios where the prefix would list svr2 but it was balanced to a different server. I am assuming it's because the appsession table takes first then sticks on that before using the cookie parameter. I have not tested with using cookie as an inserted option (not prefix on existing cookie) but I am thinking it would yield similar results.

My question is: Which one is checked first, appsession or cookie, and is it an immediate catch after it reads the first one, or a fall through? Also as a follow up - is it not recommended to use both in the same backend?

Cookie as I understand takes less memory resources, is agnostic to reloads and has way better reliability of persistence. Appsession I assume takes less cpu resource, since it's reading not writing.

(Bonus Question: is there a way to inspect appsession/cookie table map? socket> show table doesn't show anything except stick-tables)

Many thanks in advance,

-Nick

© Server Fault or respective owner

Related posts about haproxy