Skip to content

Commit

Permalink
Add jitter on the processor fetch backoff sleep (#868)
Browse files Browse the repository at this point in the history
  • Loading branch information
pior authored Oct 19, 2024
1 parent f4b5649 commit 95a0768
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 95a0768

Please sign in to comment.