]> git.ipfire.org Git - thirdparty/haproxy.git/commit
MEDIUM: server: use the two thresholds for the connection release algorithm
authorWilly Tarreau <w@1wt.eu>
Mon, 29 Jun 2020 18:55:53 +0000 (20:55 +0200)
committerWilly Tarreau <w@1wt.eu>
Mon, 29 Jun 2020 19:54:38 +0000 (21:54 +0200)
commitddfe0743d8986a1ff71cba5e5ac863e69a4e8e2a
treec26e6da526d98541cf6ff914c8268e96ed15bef4
parente69282a03f5ced81161f18f1aba4f737382f0c56
MEDIUM: server: use the two thresholds for the connection release algorithm

The algorithm improvement in bdb86bd ("MEDIUM: server: improve estimate
of the need for idle connections") is still not enough because there's
a hard limit between below and above the FD count, so it continues to
end up with many killed connections.

Here we're proceeding differently. Given that there are two configured
limits, a low and a high one, what we do is that we drop connections
when the high limit is reached (what's already done by the killing task
anyway), when we're between the low and the high threshold, we only keep
the connection if our idle entries are empty (with a preference for safe
ones), and below the low threshold, we keep any connection so as to give
them a chance of being reused or taken over by another thread.

Proceeding like this results in much less dropped connections, we
typically see a 99.3% reuse rate (76k conns for 10M requests over 200
servers and 4 threads, with 335k takeovers or 3%), and much less CPU
usage variations because there are no more bursts to try to kill extra
connections.

It should be possible to further improve this by counting the number
of threads exploiting a server and trying to optimize the amount of
per-thread idle connections so that it is approximately balanced among
the threads.
include/haproxy/server.h