LVS TCP connection timeouts – lingering connections

load balancinglvs

I'm using keepalived to load-balance connections between a number of TCP servers. I don't expect it matters, but the service in this case is rabbitmq. I'm using NAT type balancing with weighted round-robin.

A client connects to the server thus:

[client]-----------[lvs]------------[real server]
            a                b

If a client connects to the LVS and remains idle, sending nothing on the socket, this eventually times out, according to timeouts set using ipvsadm --set. At this point, the connection marked 'a' above correctly disappears from the output of netstat -anp on the client, and from the output of ipvsadm -L -n -c on the lvs box. Connection 'b', however, remains ESTABLISHED according to netstat -anp on the real server box.

Why is this? Can I force lvs to properly reset the connection to the real server?

Best Answer

Do you have persistent connection enabled? The persistent connection timeout can be set using -p [timeout]

This keeps connection b active to route further requests from the client IP to the same real server.