From c2becdc40314ca18fbb35f20c292e5313949ae4e Mon Sep 17 00:00:00 2001 From: willy tarreau Date: Sun, 19 Mar 2006 19:36:48 +0100 Subject: [PATCH] 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. --- haproxy.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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); -- 2.47.3