]> git.kaiwu.me - haproxy.git/commitdiff
[BUG] global.tune.maxaccept must be limited even in mono-process mode
authorWilly Tarreau <w@1wt.eu>
Sun, 1 Mar 2009 07:35:41 +0000 (08:35 +0100)
committerWilly Tarreau <w@1wt.eu>
Sun, 8 Mar 2009 22:34:52 +0000 (23:34 +0100)
On overloaded systems, it sometimes happens that hundreds or thousands
of incoming connections are queued in the system's backlog, and all get
dequeued at once. The problem is that when haproxy processes them and
does not apply any limit, this can take some time and the internal date
does not progress, resulting in wrong timer measures for all sessions.

The most common effect of this is that all of these sessions report a
large request time (around several hundreds of ms) which is in fact
caused by the time spent accepting other connections. This might happen
on shared systems when the machine swaps.

For this reason, we finally apply a reasonable limit even in mono-process
mode. Accepting 100 connections at once is fast enough for extreme cases
and will not cause that much of a trouble when the system is saturated.
(cherry picked from commit f49d1df25cf794b8801d919fda20266d90981c78)
(cherry picked from commit d80d63b6df4fe2d8711a83f88c51a7e3a0e139ed)

doc/configuration.txt
src/haproxy.c

index 95be3d9c27d01401c714b250c2dd7d6ba4141155..adb9d2d3aac7f857d9aa99807b88cf1d6a96ccfb 100644 (file)
@@ -224,10 +224,10 @@ tune.maxaccept <number>
   Sets the maximum number of consecutive accepts that a process may perform on
   a single wake up. High values give higher priority to high connection rates,
   while lower values give higher priority to already established connections.
-  This value is unlimited by default in single process mode. However, in
+  This value is limited to 100 by default in single process mode. However, in
   multi-process mode (nbproc > 1), it defaults to 8 so that when one process
   wakes up, it does not take all incoming connections for itself and leaves a
-  part of them to other processes. Setting this value to zero or less disables
+  part of them to other processes. Setting this value to -1 completely disables
   the limitation. It should normally not be needed to tweak this value.
 
 tune.maxpollevents <number>
index f11b78638e04118b901d3b3e69ce4e5514f274c4..8cecf072632414c2cafda239e99db1b7f4cd3e6c 100644 (file)
@@ -562,11 +562,11 @@ void init(int argc, char **argv)
        if (global.tune.maxpollevents <= 0)
                global.tune.maxpollevents = MAX_POLL_EVENTS;
 
-       if (global.tune.maxaccept <= 0) {
+       if (global.tune.maxaccept == 0) {
                if (global.nbproc > 1)
                        global.tune.maxaccept = 8;  /* leave some conns to other processes */
                else
-                       global.tune.maxaccept = -1; /* accept all incoming conns */
+                       global.tune.maxaccept = 100; /* accept many incoming conns at once */
        }
 
        if (arg_mode & (MODE_DEBUG | MODE_FOREGROUND)) {