]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
[BUG] proxy: connection rate limiting was eating lots of CPU
authorWilly Tarreau <w@1wt.eu>
Mon, 7 Jun 2010 08:40:48 +0000 (10:40 +0200)
committerWilly Tarreau <w@1wt.eu>
Mon, 7 Jun 2010 20:43:54 +0000 (22:43 +0200)
The rate-limit feature relied on a timer to define how long a frontend
must remain idle. It was not considering the pending connections, so it
was almost always ready to be used again and only the accept's limit was
preventing new connections from coming in. By accounting for the pending
connection, we can compute a correct delay and effectively make the
frontend go idle for that (short) time.

src/proxy.c

index 1ee4d6d057a3f0d08f25f1f0b4fe8f91ae6ee34b..7971a7ca9e70a90f9952c9ee6ab0b1df4c532bfd 100644 (file)
@@ -485,7 +485,7 @@ void maintain_proxies(int *next)
                                goto do_block;
 
                        if (p->fe_sps_lim &&
-                           (wait = next_event_delay(&p->fe_sess_per_sec, p->fe_sps_lim, 0))) {
+                           (wait = next_event_delay(&p->fe_sess_per_sec, p->fe_sps_lim, 1))) {
                                /* we're blocking because a limit was reached on the number of
                                 * requests/s on the frontend. We want to re-check ASAP, which
                                 * means in 1 ms before estimated expiration date, because the