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 bad84a0..1b39264 100644
--- a/haproxy.c
+++ b/haproxy.c
@@ -2555,8 +2555,14 @@
struct session *s;
struct task *t;
int cfd;
+ int max_accept;
+
+ if (global.nbproc > 1)
+ max_accept = 8; /* let other processes catch some connections too */
+ else
+ max_accept = -1;
- while (p->nbconn < p->maxconn) {
+ while (p->nbconn < p->maxconn && max_accept--) {
struct sockaddr_storage addr;
socklen_t laddr = sizeof(addr);