Session affinity multiple HAProxies


Our current setup consists of Cloudflare > Multiple L4 HAProxies > Multiple L7 HAProxies > Webservers

I have a setup question, I’ve read pretty much everything about persistence, and we are currently using persistence cookies to determine the webserver to use. This works great, but though we want our users to connect to the same server as much as possible but without queueing connections or overloading the server. Cookies work great because no matter which L7 HAProxy is hit you will stay on the assigned server.

However we want them to be redispatched to other servers when the server is hitting it’s connection limit. In the currenct setup connections would get queued.

I figured we could set the maxqueue to 1, and that would help, except for that one connection which would need to wait for the server still. (I’m currently still considering this option.)

I also saw the option option prefer-last-server which would do what we want, but then I would need some kind of persistence between the L4 and L7 HAproxies. Which shouldnt really be a problem. But I am wondering should I get rid of the cookies entirely in such a config ?

I also thought of setting a maxlife for the cookies used, but I think that would result in more server switches, and that’s not what we want.

Also thought of stick tables, but I need to read myself in how to configure that. Not knowing if that is the best option for the setup we need.

So my question is, how do I make connections load balance and use the same server as much as possible without overloading that server.

Hope you can help!

Sorry to reply to my own thread,

But I have what I wanted. I use persistent cookies, but when the connection limit for a server is reached. The request is sent to a new server and the cookie is being updated.

Great product. The manual is really good, but sometimes quite hard to get a picture with what is meant for some options.

Well, maybe you can make a quick contribution to the doc/configuration.txt file to make it clearer :slight_smile: