From 95a0768ae0a03fa21eb6392f511d3b5c10e06290 Mon Sep 17 00:00:00 2001 From: Pior Bastida Date: Sat, 19 Oct 2024 09:46:48 +0200 Subject: [PATCH] Add jitter on the processor fetch backoff sleep (#868) --- processor.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/processor.go b/processor.go index 93a0b4d..29a59cd 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: