[PATCH] Improve winbind under load

Volker Lendecke Volker.Lendecke at SerNet.DE
Fri Feb 9 10:22:17 UTC 2018


Hi!

Patch looks messy, look at the result plz :-)

Review appreciated!

Thanks, Volker

-- 
Besuchen Sie die verinice.XP 2018 in Berlin,
Anwenderkonferenz für Informationssicherheit
vom 21.-23.03.2018 im Sofitel Kurfürstendamm
Info & Anmeldung hier: http://veriniceXP.org

SerNet GmbH, Bahnhofsallee 1b, 37081 Göttingen
phone: +49-551-370000-0, fax: +49-551-370000-9
AG Göttingen, HRB 2816, GF: Dr. Johannes Loxen
http://www.sernet.de, mailto:kontakt at sernet.de
-------------- next part --------------
From 13a77aff3cc825bb0829764c953de53cde6da26e Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Fri, 9 Feb 2018 10:27:55 +0100
Subject: [PATCH] winbind: Improve child selection

This improves the situation when a client request blocks a winbind
child. This might be a slow samlogon or lookupnames to a domain that's
far away. With random selection of the child for new request coming in
we could end up with a long queue when other, non-blocked children
could serve those new requests. Choose the shortest queue.

This is an immediate and simple fix. Step two will be to have a
per-domain and not a per-child queue. Right now we're pre-selecting
the check-out queue at Fry's randomly without looking at the queue
length. With this change we're picking the shortest queue. The better
change will be what Fry's really does: One central queue and red/green
lights on the busy/free checkout counters.

Signed-off-by: Volker Lendecke <vl at samba.org>
---
 source3/winbindd/winbindd_dual.c | 36 +++++++++++++++++-------------------
 1 file changed, 17 insertions(+), 19 deletions(-)

diff --git a/source3/winbindd/winbindd_dual.c b/source3/winbindd/winbindd_dual.c
index a05644d2c34..f1d11fe350a 100644
--- a/source3/winbindd/winbindd_dual.c
+++ b/source3/winbindd/winbindd_dual.c
@@ -248,33 +248,31 @@ static void wb_child_request_cleanup(struct tevent_req *req,
 	DLIST_REMOVE(winbindd_children, state->child);
 }
 
-static bool winbindd_child_busy(struct winbindd_child *child)
-{
-	return tevent_queue_length(child->queue) > 0;
-}
-
-static struct winbindd_child *find_idle_child(struct winbindd_domain *domain)
+struct winbindd_child *choose_domain_child(struct winbindd_domain *domain)
 {
+	struct winbindd_child *shortest = &domain->children[0];
+	struct winbindd_child *current;
 	int i;
 
 	for (i=0; i<lp_winbind_max_domain_connections(); i++) {
-		if (!winbindd_child_busy(&domain->children[i])) {
-			return &domain->children[i];
-		}
-	}
+		size_t shortest_len, current_len;
 
-	return NULL;
-}
+		current = &domain->children[i];
+		current_len = tevent_queue_length(current->queue);
 
-struct winbindd_child *choose_domain_child(struct winbindd_domain *domain)
-{
-	struct winbindd_child *result;
+		if (current_len == 0) {
+			/* idle child */
+			return current;
+		}
 
-	result = find_idle_child(domain);
-	if (result != NULL) {
-		return result;
+		shortest_len = tevent_queue_length(shortest->queue);
+
+		if (current_len < shortest_len) {
+			shortest = current;
+		}
 	}
-	return &domain->children[rand() % lp_winbind_max_domain_connections()];
+
+	return shortest;
 }
 
 struct dcerpc_binding_handle *dom_child_handle(struct winbindd_domain *domain)
-- 
2.11.0



More information about the samba-technical mailing list