BUG/MINOR: server: start cleaning idle connections from various points
authorWilly Tarreau <w@1wt.eu>
Mon, 29 Jun 2020 12:43:16 +0000 (14:43 +0200)
committerWilly Tarreau <w@1wt.eu>
Mon, 29 Jun 2020 12:43:16 +0000 (14:43 +0200)
commitc35bcfcc2116b46e89cad5b34656ed3eb5378d3a
treeb601c0993d6adf70e1c7a4a43c964aa08b83c523
parentb159132ea3c2448348d3db7aa97680de057efd96
BUG/MINOR: server: start cleaning idle connections from various points

There's a minor glitch with the way idle connections start to be evicted.
The lookup always goes from thread 0 to thread N-1. This causes depletion
of connections on the first threads and abundance on the last ones. This
is visible with the takeover() stats below:

 $ socat - /tmp/sock1 <<< "show activity"|grep ^fd ; \
   sleep 10 ; \
   socat -/tmp/sock1 <<< "show activity"|grep ^fd
 fd_takeover: 300144 [ 91887 84029 66254 57974 ]
 fd_takeover: 359631 [ 111369 99699 79145 69418 ]

There are respectively 19k, 15k, 13k and 11k takeovers for only 4 threads,
indicating that the first thread needs a foreign FD twice more often than
the 4th one.

This patch changes this si that all threads are scanned in round robin
starting with the current one. The takeovers now happen in a much more
distributed way (about 4 times 9k) :

  fd_takeover: 1420081 [ 359562 359453 346586 354480 ]
  fd_takeover: 1457044 [ 368779 368429 355990 363846 ]

There is no need to backport this, as this happened along a few patches
that were merged during 2.2 development.
src/backend.c
src/server.c