From b88ae180211bfde0e77e006aabd0f879239db0ae Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Tue, 29 Sep 2020 16:58:30 +0200 Subject: [PATCH] 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). --- src/backend.c | 7 +++++++ 1 file changed, 7 insertions(+) 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; }