From: Willy Tarreau Date: Tue, 29 Sep 2020 14:58:30 +0000 (+0200) Subject: OPTIM: backend/random: never queue on the server, always on the backend X-Git-Tag: v2.3-dev6~129 X-Git-Url: http://www.kaiwu.me/postgresql/commit/?a=commitdiff_plain;h=b88ae180211bfde0e77e006aabd0f879239db0ae;p=haproxy.git OPTIM: backend/random: never queue on the server, always on the backend If random() returns a server whose maxconn is reached or the queue is used, instead of adding the request to the server's queue, better add it to the backend queue so that it can be served by any server (hence the fastest one). --- diff --git a/src/backend.c b/src/backend.c index 44cda1a28..35e6f781d 100644 --- a/src/backend.c +++ b/src/backend.c @@ -548,6 +548,13 @@ static struct server *get_server_rnd(struct stream *s, const struct server *avoi curr = prev; } while (--draws > 0); + /* if the selected server is full, pretend we have none so that we reach + * the backend's queue instead. + */ + if (curr && + (curr->nbpend || (curr->maxconn && curr->served >= srv_dynamic_maxconn(curr)))) + curr = NULL; + return curr; }