feat(health): add random delay to health monitor to prevent thundering herd problem

This commit is contained in:
yusing
2025-09-28 02:35:44 +08:00
parent 2ff5e5c0b6
commit 9d508c5950

View File

@@ -4,6 +4,7 @@ import (
"context"
"errors"
"fmt"
"math/rand"
"net/url"
"time"
@@ -141,6 +142,9 @@ func (mon *monitor) Start(parent task.Parent) gperr.Error {
failures++
}
// add a random delay between 0 and 10 seconds to avoid thundering herd
time.Sleep(time.Duration(rand.Intn(10)) * time.Second)
ticker := time.NewTicker(mon.config.Interval)
defer ticker.Stop()