1
0
Fork 0
mirror of https://github.com/deanpcmad/sidekiq-limit_fetch.git synced 2022-11-09 13:54:36 -05:00
Sidekiq strategy to support an advanced queue control – limiting, pausing, blocking, querying
Find a file
2013-01-18 15:46:58 +04:00
lib/sidekiq Add #pause and #release to Queue 2013-01-17 19:46:00 +04:00
spec Update specs for queue 2013-01-17 19:46:17 +04:00
.gitignore Initial implementation 2013-01-11 14:56:41 +04:00
Gemfile Initial implementation 2013-01-11 14:56:41 +04:00
LICENSE.txt Initial implementation 2013-01-11 14:56:41 +04:00
Rakefile Initial implementation 2013-01-11 14:56:41 +04:00
README.md Give hint about upcoming global locks support 2013-01-18 15:46:58 +04:00
sidekiq-limit_fetch.gemspec Update dependency on sidekiq 2013-01-18 08:58:08 +04:00

Description

Sidekiq strategy to restrict number of workers which are able to run specified queues simultaneously.

Installation

Add this line to your application's Gemfile:

gem 'sidekiq-limit_fetch'

Usage

Specify limits which you want to place on queues inside sidekiq.yml:

:limits:
  queue_name1: 5
  queue_name2: 10

Or set it dynamically in your code:

  Sidekiq::Queue.new('queue_name1').limit = 5
  Sidekiq::Queue['queue_name2'].limit = 10

In these examples, tasks for the queue_name1 will be run by at most 5 workers at the same time and the queue_name2 will have no more than 10 workers simultaneously.

Ability to set limits dynamically allows you to resize worker distribution among queues any time you want.

You can also pause your queues temporarely. Upon continuing their limits will be preserved.

  Sidekiq::Queue['name'].pause # prevents workers from running tasks from this queue
  ...
  Sidekiq::Queue['name'].continue # allows workers to use the queue with the same limit

Limits are applied per process. In case you have several worker processes and want to have global locks between them, you'll need to wait just a bit more since support for global locks is underway.

Sponsored by [Evil Martians]. [Evil Martians]: http://evilmartians.com/