[MEDIUM] improve behaviour with large number of servers per proxy
When a very large number of servers is configured (thousands),
shutting down many of them at once could lead to large number
of calls to recalc_server_map() which already takes some time.
This would result in an O(N^3) computation time, leading to
noticeable pauses on slow embedded CPUs on test platforms.
Instead, mark the map as dirty and recalc it only when needed.
diff --git a/src/checks.c b/src/checks.c
index 4c8a009..2c581ef 100644
--- a/src/checks.c
+++ b/src/checks.c
@@ -46,7 +46,8 @@
/* Sets server <s> down, notifies by all available means, recounts the
* remaining servers on the proxy and transfers queued sessions whenever
- * possible to other servers.
+ * possible to other servers. It automatically recomputes the number of
+ * servers, but not the map.
*/
static void set_server_down(struct server *s)
{
@@ -58,7 +59,7 @@
if (s->health == s->rise) {
recount_servers(s->proxy);
- recalc_server_map(s->proxy);
+ s->proxy->map_state |= PR_MAP_RECALC;
/* we might have sessions queued on this server and waiting for
* a connection. Those which are redispatchable will be queued
@@ -454,7 +455,7 @@
int xferred;
recount_servers(s->proxy);
- recalc_server_map(s->proxy);
+ s->proxy->map_state |= PR_MAP_RECALC;
/* check if we can handle some connections queued at the proxy. We
* will take as many as we can handle.