From: willy tarreau Date: Sun, 19 Mar 2006 18:36:48 +0000 (+0100) Subject: Limit the number of consecutive accept() in multi-process mode. X-Git-Tag: v1.2.10~8 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c2becdc40314ca18fbb35f20c292e5313949ae4e;p=thirdparty%2Fhaproxy.git Limit the number of consecutive accept() in multi-process mode. This produces a more evenly distributed load across the processes and slightly improves performance by reducing bottlenecks. --- diff --git a/haproxy.c b/haproxy.c index bad84a0974..1b39264a3e 100644 --- a/haproxy.c +++ b/haproxy.c @@ -2555,8 +2555,14 @@ int event_accept(int fd) { struct session *s; struct task *t; int cfd; + int max_accept; - while (p->nbconn < p->maxconn) { + if (global.nbproc > 1) + max_accept = 8; /* let other processes catch some connections too */ + else + max_accept = -1; + + while (p->nbconn < p->maxconn && max_accept--) { struct sockaddr_storage addr; socklen_t laddr = sizeof(addr);