not sure if it works correctly but we tried to tune the AR connections. In a Rails initialiser, we have: ```ruby # More info: # - https://devcenter.heroku.com/articles/concurrency-and-database-connections#threaded-servers # Rails.application.config.after_initialize do ActiveRecord::Base.connection_pool.disconnect! ActiveSupport.on_load(:active_record) do config = ActiveRecord::Base.configurations[Rails.env] || Rails.application.config.database_configuration[Rails.env] # This configure the maximum number of connection that AR is allowed to boot. # Not the number of connection that AR will boot. # # We're in a multi-threaded environment and AR is using a connection per thread. # We don't really know how many thread will be used by the execution of our program, # so we don't really know how many DB connections we'll need. # So, here, I configure AR with a, hopefully, large enough number, so we'll not have connections problems. # # It's a shitty thing to do, because unsafe, but it seems to be the best way to do this with Rails... # # If you encounter some problems, you can increase the multiplicator. # config['pool'] = 128 ActiveRecord::Base.establish_connection(config) end end ```