I am trying to load balance with haproxy on VirtualBox just to see that things work as they should before I go on to set it up on Digital Ocean. I am able to decide how to balance requests when I choose mode http, but when I choose mode tcp, all requests from the same machine/client goes to the same server, and does not alternate. I would like it to alternate with either roundrobin or leastconn. I would like to set up the simplest configuration file that is possible to achieve this. This is what I have so far. But it is not working as I described.

    chroot      /var/lib/haproxy
    pidfile     /var/run/haproxy.pid
    maxconn     4096
    user        haproxy
    group       haproxy

    mode tcp

frontend main *:80
    default_backend nodes

backend nodes
    balance roundrobin
    server goapp1 check
    server goapp2 check

How can I achieve this?


Disable HTTP connection re-use on your web servers. In TCP mode, haproxy doesn't know that the HTTP transaction has logically concluded.

  • I understood the first sentence, I can probably disable the keepalive setting to disable re-use of TCP connections between different HTTP requests. But couldn't understand the last part, "haproxy doesn't know that the HTTP transaction has logically concluded". What does this mean? Thanks for the answer by the way! Alex – Alex Apr 26 '16 at 16:59
  • I got this answer from someone else: "You simply can't load balance at the transport layer, and have it distribute requests based on the session layer or higher. The load balancer must understand the protocol you expect it to load-balance." – Alex Apr 26 '16 at 19:33
  • Test with multiple clients and you will see that it works fine, single test clients always look weird. – Malcolm turnbull Apr 28 '16 at 7:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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