Skip to content

Instantly share code, notes, and snippets.

@trak3r
Created April 14, 2015 14:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save trak3r/a9ed9ebad1db0696406a to your computer and use it in GitHub Desktop.
Save trak3r/a9ed9ebad1db0696406a to your computer and use it in GitHub Desktop.
module Delayed
class Worker
class << self
def sleep_delay_with_fudging
# stagger sleeps by +/- 10% so all the workers don't spike at same time
sleep_delay_without_fudging * rand(0.9..1.1)
end
alias_method_chain :sleep_delay, :fudging
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment