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 15, 2024
1 parent 8df0bfa commit 6d64626
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 6d64626

Please sign in to comment.