]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
OPTIM: backend/random: never queue on the server, always on the backend
authorWilly Tarreau <w@1wt.eu>
Tue, 29 Sep 2020 14:58:30 +0000 (16:58 +0200)
committerWilly Tarreau <w@1wt.eu>
Tue, 29 Sep 2020 15:18:11 +0000 (17:18 +0200)
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

index 44cda1a28111ab5197d54a9ee2928dc1d3a0b255..35e6f781d0ab4334381368e72ba1f344445644e1 100644 (file)
@@ -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;
 }