]> git.ipfire.org Git - thirdparty/haproxy.git/commit
MAJOR: connection: purge idle conn by last usage
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Mon, 21 Aug 2023 16:32:29 +0000 (18:32 +0200)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Fri, 25 Aug 2023 13:57:48 +0000 (15:57 +0200)
commit5afcb686b93c3811bd859a331efd6a8341a61218
treece245fe5342994b85390b29048886fa78dd56b7d
parent61fc9568fb6546aa256144220db37e6548c1e5d7
MAJOR: connection: purge idle conn by last usage

Backend idle connections are purged on a recurring occurence during the
process lifetime. An estimated number of needed connections is
calculated and the excess is removed periodically.

Before this patch, purge was done directly using the idle then the safe
connection tree of a server instance. This has a major drawback to take
no account of a specific ordre and it may removed functional connections
while leaving ones which will fail on the next reuse.

The problem can be worse when using criteria to differentiate idle
connections such as the SSL SNI. In this case, purge may remove
connections with a high rate of reusing while leaving connections with
criteria never matched once, thus reducing drastically the reuse rate.

To improve this, introduce an alternative storage for idle connection
used in parallel of the idle/safe trees. Now, each connection inserted
in one of this tree is also inserted in the new list at
`srv_per_thread.idle_conn_list`. This guarantees that recently used
connection is present at the end of the list.

During the purge, use this list instead of idle/safe trees. Remove first
connection in front of the list which were not reused recently. This
will ensure that connection that are frequently reused are not purged
and should increase the reuse rate, particularily if distinct idle
connection criterias are in used.
include/haproxy/connection-t.h
include/haproxy/server-t.h
src/backend.c
src/connection.c
src/server.c