1
0
Fork 0
mirror of https://github.com/mperham/sidekiq.git synced 2022-11-09 13:52:34 -05:00

Randomize initial scheduler timing

This commit is contained in:
Mike Perham 2014-06-07 20:57:33 -07:00
parent eac17801bd
commit 20cf90d003

View file

@ -5,7 +5,7 @@ require 'sidekiq/actor'
module Sidekiq module Sidekiq
module Scheduled module Scheduled
INITIAL_WAIT = 15 INITIAL_WAIT = 10
## ##
# The Poller checks Redis every N seconds for messages in the retry or scheduled # The Poller checks Redis every N seconds for messages in the retry or scheduled
@ -79,7 +79,11 @@ module Sidekiq
def initial_wait def initial_wait
begin begin
# Have all processes sleep between 10-15 seconds. 10 seconds
# to give time for the heartbeat to register and 5 random seconds
# to ensure they don't all hit Redis at the same time.
sleep(INITIAL_WAIT) sleep(INITIAL_WAIT)
sleep(5 * rand)
rescue Celluloid::Task::TerminatedError rescue Celluloid::Task::TerminatedError
# Hit Ctrl-C when Sidekiq is finished booting and we have a chance # Hit Ctrl-C when Sidekiq is finished booting and we have a chance
# to get here. # to get here.