20

HAProxy gives you the option to set the mode to TCP or HTTP. It also allows you to set the port.

So why allow me to choose between HTTP and TCP, if it's letting me choose the port too? Surely if I wanted HTTP I could just choose TCP and port 80?

Why only TCP and HTTP? It seems to imply that HTTP is not TCP. Why not have TCP, HTTP, SNMP, FTP, etc, etc, etc..

Why just HTTP and TCP? Why have either of those options if HTTP is TCP? Find it very confusing, and it's really difficult to find any information about load balancing non-http(s) services.

2 Answers 2

33

By using the HTTP method in the HAProxy config, you have access to several HTTP-specific options. For example, you can choose different backends based on the URL in the HTTP request. When specifying TCP mode, HAProxy does not evaluate the HTTP headers in the packet.

So, you can definitely just use TCP for HTTP traffic, but you wouldn't have the additional HTTP options. As a side note, unless you're using the SSL features, you have to use TCP for HTTPS traffic because the packets are encrypted and HAProxy can't view the HTTP headers.

1
  • Thanks. That's really helped make sense of it all for me. Cheers.
    – marflar
    Jul 20, 2014 at 1:57
8

Someone wrote a blog post on this: http://www.linickx.com/645/load-balance-anything-with-haproxy

Anyway, I don't know why the people who maintain haproxy use the syntax they chose, I don't like it much as I find it misleading (saying something can be HTTP or TCP screws with my brain), but it turns out you can load balance anything with HAProxy, and if it's not HTTP(s) then just go with TCP and the correct port number.

1
  • HTTP is TCP at the transport layer, so the entire application is just TCP with some specialization for HTTP. Good link, by the way.
    – signus
    Feb 21, 2017 at 5:01

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .