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.

It seems like HAProxy doesn't allow this. We have Tomcat servers on the backend and are planning to use Apache + mod_jk to load balance. We're considering switching to something more full-featured like Netscaler but I'm not sold since part of what I'm looking for is the ability to do a seamless deployment where I could remove one of the Tomcat servers from the load balancer before rebooting it.

share|improve this question

closed as not constructive by Chris S Dec 24 '12 at 6:10

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.If this question can be reworded to fit the rules in the help center, please edit the question.

3  
HAProxy allows it... check this... serverfault.com/questions/249316/… –  Marcelo Bittencourt Oct 26 '11 at 20:19
    
Shopping Questions are Off-Topic on any of the Stack Exchange sites. See [Q&A is hard, lets go Shopping]blog.stackoverflow.com/2010/11/qa-is-hard-lets-go-shopping) and the FAQ for more details. –  Chris S Dec 24 '12 at 6:10

6 Answers 6

up vote 5 down vote accepted

HAProxy allows you to do this by passing a command into the stats socket to disable the server. This will drain the connections (existing connections to this server will persist, but no new connections will be made to it).

This page gives a good summary of the commands available: http://code.google.com/p/haproxy-docs/wiki/UnixSocketCommands

and a disable example:

echo "disable server <backend_name>/<server_name>" | socat stdio /var/run/haproxy.stat

where /var/run/haproxy.stat is the UNIX domain socket for the commands, which is configured in the haproxy config file like so:

global
    stats socket /var/run/haproxy.stat mode 600 level admin

alongside any other global options.

Not you don't have to communicate on the socket via socat, you can connect to it like any other UNIX domain socket, which is quite straightforward in Python, Perl, PHP, C, etc. socat is mainly used in examples for convenience.

share|improve this answer

Apache can do it if you use mod_proxy instead of mod_jk; mod_proxy_balancer can integrate with mod_status for a mess-with-balancer-nodes page. See here.

share|improve this answer

I use LVS (www.linuxvirtualserver.org), which allows you to change a server's weight or remove it from rotation any time. Very handy when I need to install updates on web servers.

share|improve this answer

So long as your application allows user session-state to be served from all of the servers behind the load-balancer, pretty much all load-balancers support this. If your application sessions are sticky to the physical server the user is communicating with, your best bet is to disallow new connections to the server you want to take out of service and wait until the sessions have all closed. Depending on your app, this could be seconds or hours.

share|improve this answer

NGINX will allow you to do this, and to do non-fair load balances.

upstream Defintion blocks allow you to set various settings about the upstream servers that requests will be sent to.

  • This server is down
  • This server is only for backup, do not use if any other servers are up
  • stop using this server if it fails more than X times
  • how often to retest an upstream to see if it is back up
  • weighting each server, allowing you to direct traffic to where your capacity is.
  • use 'ip_hash', which will make clients 'sticky' to a backend as long as it is up. The same client will always go to the same backend, this is required by some applications that have persistent session data that is not replicated to the other upstreams

There is also the proxy_next_upstream setting which allows you to have NGINX automatically try a different backend if one returns an unsatisfactory result.

share|improve this answer

An alternative to @James Little's suggestion of socat you could also use hatop to connect to the HAProxy CLI to run the disable (or any of the other commands):

hatop -s /var/run/haproxy.stat

Then hit 5 (listed as 5-CLI in the bottom left menu bar). This will provide you with a prompt where you can enter commands for HAProxy.

share|improve this answer

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