HAProxy ALOHA Documentation 15.5

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 can carry any higher-level protocol such as HTTP, SMTP, Redis, MySQL, NFS, or others.

Proxying TCP can be faster than proxying HTTP because it does not incur the overhead of reading application-level metadata such as HTTP headers.

TCP load balancing functions as follows:

  1. The client connects to your application at the configured public IP address. The HAProxy ALOHA listens at that address and receives the packets.

  2. 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.

  3. The backend server sends its response back to HAProxy ALOHA and then HAProxy ALOHA relays it back to the client over the frontend connection.

TCP load balancing is configured using the layer 7 load balancer via the LB Layer7 tab.

Set TCP mode

  1. In the web UI's LB Layer7 tab, set the mode directive to tcp in both the frontend and backend sections of your configuration to load balance TCP connections. The default mode is tcp, but it is still good practice to specify it.

    In the following example, we load balance MySQL servers. Typically, it is best to set the load balancing algorithm to least connections (leastconn) 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
  2. Click on the Setup tab. In the Configuration section, click Save.


Next up

UDP