Search code examples
ruby-on-rails-3.2sidekiq

sidekiq ignoring pool size setting


No matter what I try, I can't seem to get Sidekiq to honour my max pool size settings. I've tried:

  • setting pool in my database:
production:
  adapter: mysql2
  encoding: utf8
  database: database
  username: username
  password: password
  host: host
  reconnect: true
  pool: 10
  • hard-coding it in my sidekiq initializer (both with and without the disconnect! and both inside and outside the configure server block):
Sidekiq.configure_server do |config|
  ActiveRecord::Base.connection.disconnect!
  ActiveRecord::Base.configurations['production']['pool'] = 50
  ActiveRecord::Base.establish_connection
end
database_url = ENV['DATABASE_URL']
if(database_url)
  ENV['DATABASE_URL'] = "#{database_url}?pool=25"
  ActiveRecord::Base.establish_connection
end

I have no idea why none of these have worked. Any ideas?

In case it's relevant:

  • rails 3.2.12
  • sidekiq 2.6.4

Solution

  • Make sure that you're not manually establishing connections in any of the workers, or in any of the code the workers execute. This will increase the number of connections that each worker checks out from the pool (unnecessarily) and will cause your universe to collapse.