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 wanted to use HAProxy for my web app for load balancing purpose. I am trying to add a new rabbitmq node dynamically in HAProxy server using command : haproxy -p /var/run/ -sf $(cat /var/run/ I am doing tcp connection mode with leastconn balance algorithm in load balancing. What is expected is when there is 3 connection in one rabbitmq, I add a new rabbit server in HAProxy server. so the next connection would pass to 2nd rabbitmq server which is not happening in my case. It distributes the connection in haphazardly manner.

Here is my config file:

        log     global
        mode    http
        option  httplog
        option  dontlognull
        retries 3
        option redispatch
        maxconn 2000
        contimeout      5000
        clitimeout 5000
        srvtimeout 5000
listen rabbitmq
         mode    tcp
         stats   enable
         balance leastconn
        option tcplog
        server  rabbit01 xx.xx.xx.xx:5672 check
        server  rabbit02 xx.xx.xx.xx:5672 check
listen tomcatq
         mode    http
         stats   enable
         balance roundrobin
         stats refresh 10s
        stats refresh 10s
        stats uri     /lb?stats
        stats auth    admin:admin
         option httplog         

What is the problem causing this behavior? Any suggestion will appreciated.

share|improve this question

The HAProxy docs say regarding the leastconn balancing algorithm:

Use of this algorithm is recommended where very long sessions are expected, such as LDAP, SQL, TSE, etc... but is not very well suited for protocols using short sessions such as HTTP.

I'm not sure how AMQP works but I don't think you'll see perfect results especially with a low number of connections with leastconn. Based off your details it doesn't seem like you're adding the node dynamically, it actually just appears you're restarting the HAProxy instance?

share|improve this answer
no i am not restarting HAProxy instance. I have checked that if I restart the HAProxy server my all connection which are already established will disconnected. So i am using the command described in this link:… – Anand Soni May 14 '12 at 8:47
Yes you are. The command does a graceful handoff between the old process and the new one. The existing connections stay open on the old one and the new one services new requests. – JamesRyan Jan 26 '14 at 23:10

Not sure how do you add node to haproxy. Did the new node already exist in the haproxy.cfg? If you add node with the command: haproxy -p /var/run/ -sf $(cat /var/run/, haproxy will be restarting, all the connection info will be cleared. So the new connection may not be dispatched to 2nd rabbitmq server.

share|improve this answer

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.