TCP load balancing in HAProxy with persistent TCP connections

haproxyload balancingpersistent-connectiontcp

Currently, I have a single client (component) having a single persistent TCP connection with the server(another component), and messages are exchanged asynchronously. I wanted to have a load balancer (HAProxy preferably) where the connection b/w client and load balancer as well as b/w load balancer and multiple servers as persistent TCP connection.

I know HAProxy can easily be set up for the TCP load balancing, but I wanted to know does it support persistent connections out of the box. Would be great help if someone points me in the right direction. Thanks.

Best Answer

Yes it supports persistent TCP connections right out of the box. A simple implementation in the haproxy looks like this

listen tcpProxy 0.0.0.0:7000 
    mode tcp 
    balance source
    server tcp1 ip1:port check maxconn 10000
    server tcp2 ip2:port check maxconn 10000

Hope this helps

Related Topic