diff options
Diffstat (limited to 'config/initializers/sidekiq.rb')
-rw-r--r-- | config/initializers/sidekiq.rb | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/config/initializers/sidekiq.rb b/config/initializers/sidekiq.rb index 023af2af23c..6e660a8c026 100644 --- a/config/initializers/sidekiq.rb +++ b/config/initializers/sidekiq.rb @@ -1,3 +1,6 @@ +require 'gitlab/current_settings' +include Gitlab::CurrentSettings + # Custom Redis configuration redis_config_hash = Gitlab::Redis.params redis_config_hash[:namespace] = Gitlab::Redis::SIDEKIQ_NAMESPACE @@ -29,6 +32,19 @@ Sidekiq.configure_server do |config| end Sidekiq::Cron::Job.load_from_hash! cron_jobs + # allow it to fail: it may do so when create_from_defaults is executed before migrations are actually done + begin + throttling_enabled = current_application_settings.sidekiq_throttling_enabled + rescue + throttling_enabled = false + end + + if throttling_enabled + { 'project_cache' => 0.1, 'pipeline' => 0.1 }.each do |queue, ratio| + Sidekiq::Queue[queue].limit = (ratio * Sidekiq.options[:concurrency]).ceil + end + end + # 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] || |