film42 / sidekiq-rs

A port of sidekiq to rust using tokio
MIT License
95 stars 10 forks source link

Add a yield to prevent `Processor` from hogging redis connections #44

Closed spencewenski closed 2 months ago

spencewenski commented 2 months ago

Problem

When there are no sidekiq jobs available in redis, there are no awaits between when brpopreturns and when the next connection is acquired from the pool. This means tokio's task scheduler doesn't have a chance to switch to another task that's waiting for a connection.

Solution

Add a tokio::task::yield_now().await in the case where there is no actual job to handle. This allows tokio's task scheduler to wake up a different task that's waiting for a connection.

https://github.com/film42/sidekiq-rs/issues/43

film42 commented 2 months ago

Released as version v0.10.4 ❤️ !