Skip to content

A Resque plugin for processing queues from random jobs based on queue weightings. Inspired by resque-fairly.

License

Notifications You must be signed in to change notification settings

seomoz/resque-unfairly

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Status: Production Open Source: yes Team: Research Tools

resque-unfairly

Usually Resque workers work on queues in the given order (if there is something in the first, work it, otherwise if the there is something in the second, work on it, and so on). This plugin randomizes the order of the queues based on weights, so that a given queue will be the first queue to try based on a probability weight. Given queues A, B, C, D and weights 4, 3, 2, 1, repsectively, A will be first 40% of the time, B 30%, C 20%, and D 10%. In addition, when B is first, A will be second 4/7ths of the time (4 / [4+2+1]), and so on. The project is inspired by resque-fairly by Peter Williams, which unfortunately mathematically does not give you this control over the weights.

Example usage

require 'resque'
require 'resque/plugins/unfairly'

Resque::Plugins::Unfairly::prioritize("myqueue", 1)
Resque::Plugins::Unfairly::prioritize("myotherqueue", 3)
Resque::Plugins::Unfairly::prioritize("someotherqueue", 6)

Now, workers processing all three queues will (assuming all queues have jobs) take jobs from someotherqueue 60% of the time, myotherqueue 30% of the time, and myqueue 10% of the time. This is achieved by reordering the queues, so if someotherqueue is empty, the workers will take jobs from myotherqueue 75% (3/4) of the time.

About

A Resque plugin for processing queues from random jobs based on queue weightings. Inspired by resque-fairly.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages