TCP
HAProxy ALOHA 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 (e.g. HTTP, SMTP, Redis, MySQL). Because it does not read application-level metadata such as HTTP headers, proxying involves less overhead and can be faster.
The client connects to your application at the configured public IP address. The HAProxy ALOHA listens at that address and receives the packets.
HAProxy ALOHA makes a separate connection to one of the backend servers and relays the packets over that connection. In other words, the client's original connection is not routed to a backend server directly. Instead, the client communicates with the HAProxy ALOHA only.
The backend server sends its response back to HAProxy ALOHA and then HAProxy ALOHA relays it back to the client over the frontend connection.
Set TCP mode
-
In the web UI's LB Layer 7 tab, set the
mode
directive to tcp in both thefrontend
andbackend
sections of your configuration to load balance TCP connections. Note that if you do not specify themode
, it defaults to tcp.In the following example, we load balance MySQL servers. Typically, it is 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.
Set the mode to tcp to load balance TCP traffic.
frontend mysql mode tcp bind :3306 default_backend mysql_servers backend mysql_servers mode tcp balance leastconn server s1 192.168.0.10:3306 server s2 192.168.0.11:3306
Next up
Direct Server Return