Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have installed Pound (for SSL off-load) and HAproxy on Debian 6 Squeeze. I am trying to understand the HAProxy documentation to set up sticky sessions as this load balancer will go in front of a web app.

I have also had a look around Server Fault for others' configuring HAProxy for sticky sessions; The obvious way I have seen all over the Internet is something like this under a backend statement;

balance roundrobin
stick store-request src 
stick-table type ip size 200k expire 2m
server web1 10.0.0.2:8080 check
server web2 10.0.0.3:8080 check

The other less common method I have seen is to use the option appsession, as doucmented here.

Which should I be using, or both? And why?

Thank you.

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

it depends on what is best for your application. if your web app uses cookies to do session tracking, then appsession is a good way of doing it. however, if your site uses SSL/TLS and the encryption is on the backend, then haproxy can't read the cookies and you have to use IP. since you're offloading the SSL with pound (assuming it's in front of haproxy) then this shouldn't be a problem for you.

alternatively, if you session state is stored entirely in the cookie or in storage shared between you backend servers (i.e., your database) then you don't need stickiness at all.

probably the reason you don't see appsession used as much in examples is that it's slightly more work then IP stickiness and not always worth the effort, especially since almost everything these days stores session state in shared storage.

share|improve this answer
    
Thanks for the great answer, I have finally had a chance to play around with this, cheers! –  jwbensley Oct 17 '12 at 14:58
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.