2
0
mirror of https://github.com/hibiken/asynq.git synced 2024-11-14 11:31:18 +08:00

Add jitter on the processor fetch backoff sleep (#868)

This commit is contained in:
Pior Bastida 2024-10-19 09:46:48 +02:00 committed by GitHub
parent f4b56498f2
commit 95a0768ae0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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: