Skip to content

Commit

Permalink
Add jitter on the processor fetch backoff sleep
Browse files Browse the repository at this point in the history
  • Loading branch information
pior committed Apr 25, 2024
1 parent 2b632b9 commit 61d5816
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 61d5816

Please sign in to comment.