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:
parent
d2c927a7b2
commit
52828e4212
3 changed files with 31 additions and 0 deletions
18
Changes.md
18
Changes.md
|
@ -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
|
||||
-----------
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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]
|
||||
|
|
Loading…
Add table
Reference in a new issue