The default worker considers the order of queues as their priority order,
The default worker considers the order of queues as their priority order,
and if a task is pending in a higher priority queue
and if a task is pending in a higher priority queue
it will be selected before any other in queues with lower priority.
it will be selected before any other in queues with lower priority (the `default` behavior).
To choose the strategy that should be used, `rq` provides the `--dequeue-strategy / -ds` option.
In certain circumstances it can be useful that a when a worker is listening to multiple queues,
In certain circumstances it can be useful that a when a worker is listening to multiple queues,
say `q1`,`q2`,`q3`, the jobs are dequeued using a Round Robin strategy. That is, the 1st
say `q1`,`q2`,`q3`, the jobs are dequeued using a Round Robin strategy. That is, the 1st
dequeued job is taken from `q1`, the 2nd from `q2`, the 3rd from `q3`, the 4th
dequeued job is taken from `q1`, the 2nd from `q2`, the 3rd from `q3`, the 4th
from `q1`, the 5th from `q2` and so on. The custom worker class `rq.worker.RoundRobinWorker`
from `q1`, the 5th from `q2` and so on. To implement this strategy use `-ds round_robin` argument.
implements this strategy.
In some other circumstances, when a worker is listening to multiple queues, it can be useful
In other circumstances, it can be useful to pull jobs from the different queues randomly.
to pull jobs from the different queues randomly. The custom class `rq.worker.RandomWorker`
To implement this strategy use `-ds random` argument.
implements this strategy. In fact, whenever a job is pulled from any queue, the list of queues is
In fact, whenever a job is pulled from any queue with the `random` strategy, the list of queues is
shuffled, so that no queue has more priority than the other ones.
shuffled, so that no queue has more priority than the other ones.
Deprecation Warning: Those strategies were formely being implemented by using the custom classes `rq.worker.RoundRobinWorker`
and `rq.worker.RandomWorker`. As the `--dequeue-strategy` argument allows for this option to be used with any worker, those worker classes are deprecated and will be removed from future versions.