diff --git a/include/common/defaults.h b/include/common/defaults.h index 198288fb9..2c757d2f5 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 1d8f2b301..57242f11e 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++;