1
0
Fork 0
mirror of https://github.com/mperham/sidekiq.git synced 2022-11-09 13:52:34 -05:00

Tune concurrency via env, fixes #2985

This commit is contained in:
Mike Perham 2016-08-01 09:33:12 -07:00
parent d2c927a7b2
commit 52828e4212
3 changed files with 31 additions and 0 deletions

View file

@ -1,5 +1,23 @@
# Sidekiq Changes
HEAD
-----------
- Allow tuning of concurrency with the `RAILS_MAX_THREADS` env var. [#2985]
This is the same var used by Puma so you can tune all of your systems
the same way:
```sh
web: RAILS_MAX_THREADS=5 bundle exec puma ...
worker: RAILS_MAX_THREADS=10 bundle exec sidekiq ...
```
Using `-c` or `config/sidekiq.yml` overrides this setting. I recommend
adjusting your `config/database.yml` to use it too so connections are
auto-scaled:
```yaml
pool: <%= ENV['RAILS_MAX_THREADS'] || 5 %>
```
4.1.4
-----------

View file

@ -208,6 +208,7 @@ module Sidekiq
opts = parse_config(cfile).merge(opts) if cfile
opts[:strict] = true if opts[:strict].nil?
opts[:concurrency] = Integer(ENV["RAILS_MAX_THREADS"]) if !opts[:concurrency] && ENV["RAILS_MAX_THREADS"]
options.merge!(opts)
end

View file

@ -42,6 +42,18 @@ class TestCli < Sidekiq::Test
assert_equal 60, Sidekiq.options[:concurrency]
end
it 'changes concurrency with ENV' do
begin
ENV['RAILS_MAX_THREADS'] = '9'
@cli.parse(['sidekiq', '-c', '60', '-r', './test/fake_env.rb'])
assert_equal 60, Sidekiq.options[:concurrency]
@cli.parse(['sidekiq', '-r', './test/fake_env.rb'])
assert_equal 9, Sidekiq.options[:concurrency]
ensure
ENV.delete('RAILS_MAX_THREADS')
end
end
it 'changes queues' do
@cli.parse(['sidekiq', '-q', 'foo', '-r', './test/fake_env.rb'])
assert_equal ['foo'], Sidekiq.options[:queues]