0.0
Repository is archived
No commit activity in last 3 years
No release in over 3 years
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, which unfortunately mathematically does not give you this control over the weights.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 13.0
>= 3.9

Runtime

~> 2.0
 Project Readme

resque-roulette

Why?

I've many resque workers created in the same way using splat operator to run for every queue (QUEUE=*), but to don't wait a given queue process all your jobs, I've been looking for a plugin to make that shuffle to me, and then I've found this magic plugin resque-unfairly but this is a old project and it's not in published at rubygems, so I've forked the repo and make some changes to could be published and used from rubygems instead of git directly.

Thanks for the awesome job Evan! 🍻

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.

Install

# gem 'resque'
gem 'resque-roulette'

Example usage

require 'resque'
require 'resque/plugins/roulette'

Resque::Plugins::Roulette.prioritize('myqueue' 1)
Resque::Plugins::Roulette.prioritize('myotherqueue', 3)
Resque::Plugins::Roulette.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.

Publish

  • rake build
  • rake release
  • gem push pkg/resque-roulette-<version>.gem

Authors