Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm struggling to find a solution to a specific load balancing requirement. It seems that various combinations of HAProxy, Nginx, Varnish and Apache's mod_proxy_balancer can do some but not all of what we need. My question is whether anyone can suggest a suitable configuration that would (perhaps including software that we may not have considered, but it will need to be FOSS).

The key requirement is, unfortunately, sticky sessions. We have a large, complex Tomcat app that somewhat abuses the HTTP Session, and it utilises frameworks that do the same. Converting to a stateless design or replicated session have both been investigated and discounted. Additionally, the stickiness MUST be based on a cookie and not an IP hash as we have large spikes from corporate clients where many thousands of users can all appear to be hitting the site at the same time from the same IP address.

Second most important requirement is a dynamic backend. This application runs in a cloud (not AWS) and app servers come and go from time to time based on automatic or manual scaling.

Thirdly, we need to be able to mark servers as "quiescing" so that they will continue to honour existing sessions but will not be handed new ones. When all current sessions end, the server can be turned off or upgraded/restarted.

There are some additional complications/requirements but it's meeting the three above that seems to be presenting the most difficulty.

From research so far, I think the following statements are true:

  • Nginx/Varnish can't meet the sticky session requirement (based on cookies) but HAProxy and Apache can
  • HAProxy can't do dynamic backend modification without a restart (might be ok if it's quick though). Varnish can with some VCL changes and a HUP, as could Nginx with some creative config file management I think. Apache can possibly handle this via a managed interface to mod_proxy_balancer..?
  • I'm not sure if/how any of them can deal with the third requirement

Would really appreciate any pointers or insights.

share|improve this question

With HAProxy you can add the whole range of possible backend servers and then turn them on and off (hard or soft) using the admin pages/socket calls.

How does that not fit your requirements?

share|improve this answer
Servers brought online will get a DHCP address from a /24, so adding 256 addresses as backends with about 250 disabled most of the time was not the most obvious thing to think of. There was also no description of whether disabling servers allows them to receive requests with valid persistence cookies here, which I had already read: I have now found it elsewhere in the docs, so yes, looks like it would be an option.. I'll try it over the next day or so. Thx. – darrend Jan 19 '14 at 10:15
hrm yeah, that does sound a bit unmanageable. No way you can narrow the range to what you expect to scale to? – JamesRyan Jan 19 '14 at 13:16
If it looks viable in all other respects, then yes, I can create a smaller address pool and ensure that our cloud API calls are aware of how to choose a pool when creating a new server. – darrend Jan 19 '14 at 16:46

Your Answer


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.