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 was looking for a solution for graceful reload of haproxy. I have a nginx server running which passes requests to Haproxy and at times I reload the Haproxy configuration. But I am observing that at time of reloading all the existing connections are getting cut off and haproxy backend queue shows 0 requests ( got from socket stats of haproxy ) .

I am using the method mentioned in several blog posts and haproxy documentation about the issue :

Reload :

haproxy -f /etc/haproxy/haproxy.cfg -p /var/run/ -D -sf (</var/run/

Start :

haproxy -D  -f /etc/haproxy/haproxy.cfg -p /var/run/ 

It be grateful if someone could suggest any solution. Below is my haproxy config file

  maxconn 64000
  ulimit-n 200000
  log          local0
  log          local1 notice
  spread-checks 5
  stats socket /etc/haproxy/stats

  log global
  mode http
  balance roundrobin
  maxconn 64000
  option abortonclose
  option httpclose
  retries 3
  option redispatch
  timeout client 30000
  timeout connect 30000
  timeout server 30000
  stats enable
  stats uri     /haproxy?stats
  stats realm   Haproxy Statistics
  stats auth    haproxy:stats
  timeout check 5000
share|improve this question

The command you posted does not seem 100% correct to me. On my system, it reads:

haproxy -f /etc/haproxy/haproxy.cfg -p /var/run/ -D -sf $(cat /var/run/

You mistyped the value of last option -sf.

share|improve this answer

This may be expected depending on your testing methodology. Although as mentioned above, you also seemed to be missing a $ near the end of your reload command?

When HAProxy does the 'reload' it starts a new HAProxy process, sends session data down a unix domain socket from the first process to the second process, the first process unbinds from the TCP ports it's listening on, and the second process binds. The first process then terminates. So they do not share memory at any stage and don't seem to sync file descriptors (from my own testing anyway). So the main point of the reload is that persistence tables (such as the cookie-based hash) are maintained so that the client will reconnect to the required backend server. However it should be graceful in the sense that connections are drained from the first process rather than instantly dropped.

If you watch your process table while performing the reload then you should observe the above, unless things have changed since I tested (a few months ago).

share|improve this answer
Hey James, thanks for the reply. The missing $ was a typo I did while posting the question, I have it in my command and the restart goes through. I have a question though, when u say "it should be graceful in the sense that connections are drained from the first process rather than instantly killed" You mean that the requests should complete and not fail. I am sending requests from ab to nginx which sends request to haproxy & i see failed requests, which I think are the requests in the queue at reload. And from your reply it seems that queue going down to 0 is expected behavior.Am I right? – vaibhav Feb 19 '12 at 23:58
@vaibhav Well an established connection should not be dropped, but remember that with HTTP, a new connection is made for each request (unless you have keepalive enabled on client and browser). Do you see successful connections after a number of failed ones? (try running ab for longer if not). If so, this could be the period where the first process is unbinding from the port(s), and the second is binding - you can't have two processes bound to the same ports at the same time. – James Little Feb 26 '12 at 9:17
I meant client and server above. – James Little Feb 26 '12 at 10:41

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.