From: Willy Tarreau Date: Sun, 14 Oct 2007 21:05:39 +0000 (+0200) Subject: [MEDIUM] only consider slow checks when looking for the common interval X-Git-Tag: v1.3.13~22 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2c43a1e2f05161cac4f88c9e9c01bd16f1b2cb5b;p=thirdparty%2Fhaproxy.git [MEDIUM] only consider slow checks when looking for the common interval When one server in one backend has a very low check interval, it imposes its value as the minimal interval, causing all other servers to start their checks close to each other, thus partially voiding the benefits of the spread checks. The solution consists in ignoring intervals lower than a given value (SRV_CHK_INTER_THRES = 1000 ms) when computing the minimal interval, and then assigning them a start date relative to their own interval and not the global one. With this change, the checks distribution clearly looks better. --- diff --git a/include/common/defaults.h b/include/common/defaults.h index 198288fb9a..2c757d2f58 100644 --- a/include/common/defaults.h +++ b/include/common/defaults.h @@ -115,4 +115,14 @@ #define DEFAULT_MAXCONN SYSTEM_MAXCONN #endif +/* Minimum check interval for spread health checks. Servers with intervals + * greater than or equal to this value will have their checks spread apart + * and will be considered when searching the minimal interval. + * Others will be ignored for the minimal interval and will have their checks + * scheduled on a different basis. + */ +#ifndef SRV_CHK_INTER_THRES +#define SRV_CHK_INTER_THRES 1000 +#endif + #endif /* _COMMON_DEFAULTS_H */ diff --git a/src/checks.c b/src/checks.c index 1d8f2b301c..57242f11e3 100644 --- a/src/checks.c +++ b/src/checks.c @@ -538,13 +538,20 @@ int start_checks() { struct task *t; int nbchk=0, mininter=0, srvpos=0; - /* 1- count the checkers to run simultaneously */ + /* 1- count the checkers to run simultaneously. + * We also determine the minimum interval among all of those which + * have an interval larger than SRV_CHK_INTER_THRES. This interval + * will be used to spread their start-up date. Those which have + * a shorter interval will start independantly and will not dictate + * too short an interval for all others. + */ for (px = proxy; px; px = px->next) { for (s = px->srv; s; s = s->next) { if (!(s->state & SRV_CHECKED)) continue; - if (!mininter || mininter > s->inter) + if ((s->inter >= SRV_CHK_INTER_THRES) && + (!mininter || mininter > s->inter)) mininter = s->inter; nbchk++; @@ -578,7 +585,8 @@ int start_checks() { t->context = s; /* check this every ms */ - tv_ms_add(&t->expire, &now, mininter * srvpos / nbchk); + tv_ms_add(&t->expire, &now, + ((mininter && mininter >= s->inter) ? mininter : s->inter) * srvpos / nbchk); task_queue(t); srvpos++;