Skip to content

Commit

Permalink
Add some jitter in the processor fetch sleep
Browse files Browse the repository at this point in the history
  • Loading branch information
pior committed Apr 11, 2024
1 parent 7b3373e commit 6360c17
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,10 @@ 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(100 * time.Millisecond)
avgWaitTime := 100
jitter := 40
waitTime := avgWaitTime - (jitter / 2) + rand.Intn(jitter)
time.Sleep(time.Duration(waitTime) * time.Millisecond)
<-p.sema // release token
return
case err != nil:
Expand Down

0 comments on commit 6360c17

Please sign in to comment.