Commit f116f87c authored by Yorick Peterse's avatar Yorick Peterse

Don't use backup AR connections for Sidekiq

Adding two extra connections does nothing other than increasing the
number of idle database connections. Given Sidekiq uses N threads it can
never use more than N AR connections at a time, thus we don't need more.

The initializer mentioned the Sidekiq upgrade guide stating this was
required.  This is false, the Sidekiq upgrade guide states this is
necessary for Redis and not ActiveRecord.

On GitLab.com this resulted in a reduction of about 80-100 PostgreSQL
connections.

Fixes #27713
parent 53db7d1d
---
title: Don't use backup Active Record connections for Sidekiq
merge_request:
author:
...@@ -36,11 +36,9 @@ Sidekiq.configure_server do |config| ...@@ -36,11 +36,9 @@ Sidekiq.configure_server do |config|
Gitlab::SidekiqThrottler.execute! Gitlab::SidekiqThrottler.execute!
# Database pool should be at least `sidekiq_concurrency` + 2
# For more info, see: https://github.com/mperham/sidekiq/blob/master/4.0-Upgrade.md
config = ActiveRecord::Base.configurations[Rails.env] || config = ActiveRecord::Base.configurations[Rails.env] ||
Rails.application.config.database_configuration[Rails.env] Rails.application.config.database_configuration[Rails.env]
config['pool'] = Sidekiq.options[:concurrency] + 2 config['pool'] = Sidekiq.options[:concurrency]
ActiveRecord::Base.establish_connection(config) ActiveRecord::Base.establish_connection(config)
Rails.logger.debug("Connection Pool size for Sidekiq Server is now: #{ActiveRecord::Base.connection.pool.instance_variable_get('@size')}") Rails.logger.debug("Connection Pool size for Sidekiq Server is now: #{ActiveRecord::Base.connection.pool.instance_variable_get('@size')}")
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment