HAProxy community

Sticky TCP load balancing


I have to load balance incoming TCP connections but the source is same for all (i.e they all are coming by a gateway), please suggest alternate options that can be used.


Literally every other load-balancing option expect source-ip stickiness.

In TCP mode, the backend session will be connected end-to-end to the frontend, so no actual stickiness should be required, in any case, it isn’t possible to achieve stickiness beyond the TCP session, when source-IP is out of question, because we cannot set cookies or learn application session IDs in a stick-table when in TCP mode.


Thanks Lukas for your advice, can we use send-proxy and accept-proxy to achieve stickiness beyond TCP session liveliness in TCP mode ? can LUA programming would be of any help?

Thanks in Advance
Ankit Singhai


No (the proxy protocol has nothing to do with it) and unlikely (but I am not a LUA expert, and it depends what the protocol looks like).

What is the protocol you are load-balancing and why do you believe you need stickiness beyond the TCP session?


On backend servers we are using local caching to store the user-related information that’s why we want to calls to be sticky on server to avoid again fetching data from distributed caching server.We are using Netty 4.X to make TCP calls to HAProxy.


You need to switch to HTTP as protocol and “mode http” in haproxy. Otherwise you cannot achieve stickiness.


Thanks Lukas for your suggestion