Protocol support
TCP
HAProxy can operate as a TCP proxy, in which TCP streams are relayed through the load balancer to a pool of backend servers. The TCP stream may carry any higher-level protocol (for example, HTTP, FTP, and SMTP). Often this mode is used when clients need to communicate with applications using a specific protocol meant only for that application, such as Redis (Redis Serialization Protocol) or MySQL database servers.
There are fewer fetch methods available to inspect raw TCP streams, but also less processing overhead.
Enable TCP mode Jump to heading
Set the mode directive to tcp in both the frontend and backend sections to load balance TCP connections.
In the following example, we load balance MySQL servers. Typically, it’s best to set the load-balancing algorithm to least connections when the servers may hold the connection for a variable amount of time. That algorithm sends the next client to the server with the fewest active connections.
haproxy
haproxy
See also Jump to heading
- The mode directive should be tcpin both the frontend and the backend.
Do you have any suggestions on how we can improve the content of this page?