HAProxy HTTP vs TCP

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.


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.


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.