From 61d581648dc38b2a5b271b534ae91a22e78e7120 Mon Sep 17 00:00:00 2001 From: Pior Bastida Date: Mon, 15 Apr 2024 18:17:08 +0200 Subject: [PATCH] Add jitter on the processor fetch backoff sleep --- processor.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/processor.go b/processor.go index 0ba9890dd..a447e7b68 100644 --- a/processor.go +++ b/processor.go @@ -181,7 +181,8 @@ func (p *processor) exec() { // Sleep to avoid slamming redis and let scheduler move tasks into queues. // Note: We are not using blocking pop operation and polling queues instead. // This adds significant load to redis. - time.Sleep(p.taskCheckInterval) + jitter := time.Duration(rand.Intn(int(p.taskCheckInterval))) + time.Sleep(p.taskCheckInterval/2 + jitter) <-p.sema // release token return case err != nil: