diff options
author | Patricio Cano <suprnova32@gmail.com> | 2016-11-04 12:53:12 -0600 |
---|---|---|
committer | Patricio Cano <suprnova32@gmail.com> | 2016-11-10 11:38:10 -0600 |
commit | 9e2964c15a7d387e46e25c83afa478c12a856d77 (patch) | |
tree | d17fbb92b21696b765b1eb3d903330c5383a7213 /config | |
parent | d366a943ffe2ae6c3599c2ebc4469d49a103bacb (diff) | |
download | gitlab-ce-9e2964c15a7d387e46e25c83afa478c12a856d77.tar.gz |
Allow certain Sidekiq jobs to be throttled
Diffstat (limited to 'config')
-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] || |