MINOR: listener: improve incoming traffic distribution
authorWilly Tarreau <w@1wt.eu>
Mon, 4 Mar 2019 18:57:34 +0000 (19:57 +0100)
committerWilly Tarreau <w@1wt.eu>
Thu, 7 Mar 2019 12:48:04 +0000 (13:48 +0100)
commitfc630bd3735f6d0f0a30de4b1fa8fb192d2b186d
tree4c44853afb93f4f9ec3ef135b468a4c244e18ccb
parentb238b12e98f402e4bb042d9fda639b891da595a3
MINOR: listener: improve incoming traffic distribution

By picking two randoms following the P2C algorithm, we seldom observe
asymmetric loads on bursts of small session counts. This is typically
what makes h2load take a bit of time to complete the last 100% because
if a thread gets two connections while the other ones only have one,
it takes twice the time to complete its work.

This patch proposes a modification of the p2c algorithm which seems
more suitable to this case : it mixes a rotating index with a random.
This way, we're certain that all threads are consulted in turn and at
the same time we're not forced to use the ones we're giving a chance.

This significantly increases the traffic rate. Now h2load shows faster
completion and the average request rates on H2 and the TLS resume rate
increases by a bit more than 5% compared to pure p2c.

The index was placed into the struct bind_conf because 1) it's faster
there and it's the best place to optimally distribute traffic among a
group of listeners. It's the only runtime-modified element there and
it will be quite cache-hot.
include/types/listener.h
src/listener.c