]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
[MEDIUM] only consider slow checks when looking for the common interval
authorWilly Tarreau <w@1wt.eu>
Sun, 14 Oct 2007 21:05:39 +0000 (23:05 +0200)
committerWilly Tarreau <w@1wt.eu>
Mon, 15 Oct 2007 07:33:14 +0000 (09:33 +0200)
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.

include/common/defaults.h
src/checks.c

index 198288fb9a9651289b52df1e1771a4cf4efe058c..2c757d2f585174690c156a573e0741054216057f 100644 (file)
 #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 */
index 1d8f2b301c58e1c6e5e9ed5208d53a35570e45cf..57242f11e39078c74e41ec33bd0918487129acd2 100644 (file)
@@ -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++;