]> git.kaiwu.me - haproxy.git/commit
[OPTIM] rate-limit: cleaner behaviour on low rates and reduce consumption
authorWilly Tarreau <w@1wt.eu>
Fri, 6 Mar 2009 08:18:27 +0000 (09:18 +0100)
committerWilly Tarreau <w@1wt.eu>
Fri, 6 Mar 2009 08:18:27 +0000 (09:18 +0100)
commit79584225e559a63045b65421f1b3df474910e831
tree6584ceedeca9c46f9f1739f3694cef842ddf15d5
parentefcbc6e66d2e526bad4ad1c02e1ec2b29452b1da
[OPTIM] rate-limit: cleaner behaviour on low rates and reduce consumption

The rate-limit was applied to the smoothed value which does a special
case for frequencies below 2 events per period. This caused irregular
limitations when set to 1 session per second.

The proper way to handle this is to compute the number of remaining
events that can occur without reaching the limit. This is what has
been added. It also has the benefit that the frequency calculation
is now done once when entering event_accept(), before the accept()
loop, and not once per accept() loop anymore, thus saving a few CPU
cycles during very high loads.

With this fix, rate limits of 1/s are perfectly respected.
include/proto/freq_ctr.h
src/client.c
src/freq_ctr.c
src/proxy.c