-
Notifications
You must be signed in to change notification settings - Fork 79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Throttled workers seem to eat up a lot of processing time? #36
Comments
I believe this can be addressed by changing the return value of |
It's a bit tricky question. First of all scheduling jobs won't help a lot, because scheduled jobs is a pretty heavyweight stuff in Sidekiq. But I definitely see couple of improvements that can help:
|
Have you tried this?
|
@vincentwoo did you find a solution to your problem? :) |
A potential solution could be using multiple queues so instead of sending the throttled work to the beginning of the current queue, we could send it to a lower priority queue so we make sure the performance of the other workers that should be running won't be affected. |
Hi Alexey @ixti , Thanks for your work on this gem. It’s a brilliant solution that many projects need to have. Actually, I also encountered the problem described in this topic. As a solution, I run a separate sidekiq server in an isolated machine which processes jobs(queue) with rate limits. So it allows us not to affect other queues/servers which don’t have any rate limits. However, it's still wasting CPU time when limits are noticeably less than the outstanding work on a certain day. I really like your proposed solution (#2) since Sidekiq itself nicely deals with scheduled jobs. What do you think now if that's worth it to be done? |
@cfc1020 I think it might be worth allowing to configure how jobs should be getting back to the queue immediately or via scheduler. Probably it will make sense to make configurable queue where throttled job should be re-scheduled: sidekiq_throttled ..., :on_throttle => { :strategy => :enqueue } # current behaviour
sidekiq_throttled ..., :on_throttle => { :strategy => :schedule } # use scheduled jobs
sidekiq_throttled ..., :on_throttle => { :strategy => :schedule, :to => "throttled" }
# use scheduled jobs, but schedule to be pushed to different queue |
With v1.0.0 release you can now configure cooldown periods of queues: Sidekiq::Throttled.configure do |config|
# skip queue for 10 seconds if it returned ‹cooldown_threshold›
# throttled jobs in a row
config.cooldown_period = 10.0
# if queue returned 42 throttled jobs in a row, skip it from
# polling for the duration of ‹cooldown_period›
config.cooldown_threshold = 42
end |
I hope to get #150 merged soon (depending on my free time) so that there will be another way to aid this problem as well. |
This adds support for setting the `requeue_strategy` for a job, to specify what we should do with throttled jobs. The default is `:enqueue`, which is the current behavior: re-add it to the end of the queue. The other option is `:schedule`, which schedules the job for a time in the future when we think we'll have capacity to process it. It's also possible to set the `default_requeue_strategy` in the configuration, to set this behavior for all jobs that do not individually specify a `requeue_strategy`. This may be relevant to Issue #36. Unrelatedly, there's a commit in here that changes the format of some `require_relative` lines, to comply with the new Rubocop rule `Style/RedundantCurrentDirectoryInPath`. I don't feel strongly about this commit; I only added it so that rubocop would pass. --------- Signed-off-by: Diego Marcet <[email protected]> Co-authored-by: anero <[email protected]> Co-authored-by: Diego Marcet <[email protected]> Co-authored-by: Alexey Zapparov <[email protected]> Co-authored-by: Mauricio Novelo <[email protected]>
Hi, I'm on the latest versions of sidekiq and sidekiq-throttled.
I have a job with max rate of 10 / hr:
However, these jobs appear in the same queue as many other jobs. If I queue up hundreds of these throttled jobs, only ten will be processed (correctly!) but all the throttled ones need to move up and down the queue every second to be discarded as throttled. This chokes out a lot of other work and reduces the overall throughput of the system.
Is it possible for sidekiq-throttled to reschedule the work for later? If we know we only want 10 in an hour, we should be able to delay until we know the bucket will be refreshed, no?
The text was updated successfully, but these errors were encountered: