Skip to content

Instantly share code, notes, and snippets.

@dsshap
Created December 6, 2012 15:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save dsshap/4225296 to your computer and use it in GitHub Desktop.
Save dsshap/4225296 to your computer and use it in GitHub Desktop.
Sidekiq Autoscaler
autoscaler
sidekiq:
Sidekiq.configure_client do |config|
config.redis = { :size => 1 }
if heroku
config.client_middleware do |chain|
chain.add Autoscaler::Sidekiq::Client, heroku
end
end
end
# define HEROKU_PROCESS in the Procfile:
#
# default: env HEROKU_PROCESS=default bundle exec sidekiq -r ./background/boot.rb
# import: env HEROKU_PROCESS=import bundle exec sidekiq -q import -c 1 -r ./background/boot.rb
Sidekiq.configure_server do |config|
config.redis = { :size => 5 }
config.server_middleware do |chain|
if heroku && ENV['HEROKU_PROCESS'] && heroku[ENV['HEROKU_PROCESS']]
p "Setting up auto-scaledown"
chain.add(Autoscaler::Sidekiq::Server, heroku[ENV['HEROKU_PROCESS']], 60, [ENV['HEROKU_PROCESS']])
else
p "Not scaleable"
end
end
end
Procfile
web: bundle exec thin start -p $PORT -e $RACK_ENV
default: env HEROKU_PROCESS=default bundle exec sidekiq -c 4 -e $RACK_ENV
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment