1
0
Fork 0
mirror of https://github.com/mperham/sidekiq.git synced 2022-11-09 13:52:34 -05:00
mperham--sidekiq/test
Aaron Kromer b23c0ecf8e Use RAILS_MAX_THREADS for client pool size
This is a follow up to #2985 (52828e4) adding similar support for the
client connection pool. For Rails servers, Sidekiq is not loaded from
the CLI so the prior change to support setting the concurrency via
`RAILS_MAX_THREADS` is not applied to the web server process. This means
for Rails servers which do not configure a custom size through an
initializer they will run with the default connection pool size of 5.

When the Rails server runs the initial Redis connection may be made
through `Sidekiq::Client` (e.g. from [`ActiveJob::QueueAdapters::SidekiqAdapter`](https://github.com/rails/rails/blob/v5.1.5/activejob/lib/active_job/queue_adapters/sidekiq_adapter.rb#L20)).
This causes the `redis_pool` to be initialized without any options,
setting the pool size to the default of 5.

    .gem/ruby/2.5.0/gems/sidekiq-5.1.1/lib/sidekiq.rb:125:in `redis_pool'
    .gem/ruby/2.5.0/gems/sidekiq-5.1.1/lib/sidekiq/client.rb:42:in `initialize'
    .gem/ruby/2.5.0/gems/sidekiq-5.1.1/lib/sidekiq/client.rb:131:in `new'
    .gem/ruby/2.5.0/gems/sidekiq-5.1.1/lib/sidekiq/client.rb:131:in `push'
    .gem/ruby/2.5.0/gems/activejob-5.1.5/lib/active_job/queue_adapters/sidekiq_adapter.rb:20:in `enqueue'
    .gem/ruby/2.5.0/gems/activejob-5.1.5/lib/active_job/enqueuing.rb:51:in `block in enqueue'
    .gem/ruby/2.5.0/gems/activesupport-5.1.5/lib/active_support/callbacks.rb:108:in `block in run_callbacks'
    .gem/ruby/2.5.0/gems/activejob-5.1.5/lib/active_job/logging.rb:15:in `block (3 levels) in <module:Logging>'
    .gem/ruby/2.5.0/gems/activejob-5.1.5/lib/active_job/logging.rb:44:in `block in tag_logger'
    .gem/ruby/2.5.0/gems/activesupport-5.1.5/lib/active_support/tagged_logging.rb:69:in `block in tagged'
    .gem/ruby/2.5.0/gems/activesupport-5.1.5/lib/active_support/tagged_logging.rb:26:in `tagged'
    .gem/ruby/2.5.0/gems/activesupport-5.1.5/lib/active_support/tagged_logging.rb:69:in `tagged'
    .gem/ruby/2.5.0/gems/activejob-5.1.5/lib/active_job/logging.rb:44:in `tag_logger'
    .gem/ruby/2.5.0/gems/activejob-5.1.5/lib/active_job/logging.rb:14:in `block (2 levels) in <module:Logging>'
    .gem/ruby/2.5.0/gems/activesupport-5.1.5/lib/active_support/callbacks.rb:117:in `instance_exec'
    .gem/ruby/2.5.0/gems/activesupport-5.1.5/lib/active_support/callbacks.rb:117:in `block in run_callbacks'
    .gem/ruby/2.5.0/gems/activesupport-5.1.5/lib/active_support/callbacks.rb:135:in `run_callbacks'
    .gem/ruby/2.5.0/gems/activejob-5.1.5/lib/active_job/enqueuing.rb:47:in `enqueue'
    .gem/ruby/2.5.0/gems/activejob-5.1.5/lib/active_job/enqueuing.rb:18:in `perform_later'

For the majority of cases, a client pool size of 5 is sufficient.
However, servers which utilize a high number of threads, with large job
payloads, and which may experience some network latency issues can see
`Timeout::Error` crashes. This may be further exacerbated by the ~2-20x
performance decrease through `ActiveJob` (#3782). Rails addresses this
general type of connection issue for the main database by suggesting
that the DB pool size match the number of threads running. This change
applies that logic to the default client pool size by leveraging the
same environment setting; this way there's a connection available per
thread.

This may also have the side effect of a slight performance boost, as
there is less of a chance that threads will be blocked waiting on
connections. The trade-off is that there may be a memory profile
increase to handle the additional Redis connections in the pool; note
the pool only creates new connections as necessary to handle the
requests.

Resolves #3806
2018-03-27 15:46:57 -07:00
..
fixtures Allow dynamic sidekiq-web locale paths, for localized extensions, fixes #1261 2013-10-21 12:07:18 -07:00
config.yml Dont use logger in options parsing, fixes #1335 2013-11-13 21:33:44 -08:00
env_based_config.yml
fake_env.rb Freeze all string literals in source, fixes #2741 2015-12-31 15:33:35 -08:00
helper.rb Remove percy, the Web UI doesn’t change enough to justify the complex dependency 2017-06-06 14:54:20 -07:00
string_config.yml Symbolize all config.yml keys when loading 2017-12-02 13:37:32 -08:00
test_actors.rb Disable delay extensions by default, fixes #3174 (#3299) 2017-01-04 10:30:42 -08:00
test_api.rb Polish job failure notification 2018-01-15 10:39:32 -08:00
test_cli.rb Symbolize all config.yml keys when loading 2017-12-02 13:37:32 -08:00
test_client.rb Make Sidekiq::Client.via reentrant, fixes #3715 2018-01-10 09:53:57 -08:00
test_dead_set.rb Unified Job kill via Sidekiq::DeadSet#kill 2017-08-11 12:33:12 -07:00
test_exception_handler.rb Merge branch 'master' into frozen 2016-04-21 13:15:00 -07:00
test_extensions.rb Ensure Sidekiq.enable_delay! does not break Psych. 2017-07-29 08:49:54 +02:00
test_fetch.rb Remove namespace usage within test suite 2017-03-24 11:01:45 -07:00
test_launcher.rb Rewrite heartbeat so we can dynamically update tags/labels, #2867 2016-11-25 13:39:22 -08:00
test_logging.rb Fix minitest warnings (#3300) 2017-01-02 12:06:02 -08:00
test_manager.rb Freeze all string literals in source, fixes #2741 2015-12-31 15:33:35 -08:00
test_middleware.rb Custom job_logger_class 2017-06-07 10:20:31 -07:00
test_processor.rb Log at error level on redis exceptions and then warn for exception 2017-11-30 10:11:16 -08:00
test_rails.rb Freeze all string literals in source, fixes #2741 2015-12-31 15:33:35 -08:00
test_redis_connection.rb Use RAILS_MAX_THREADS for client pool size 2018-03-27 15:46:57 -07:00
test_retry.rb fix: use default when returned 0 2018-03-22 09:04:28 -07:00
test_retry_exhausted.rb rename API to death handlers for consistency 2018-01-31 10:22:22 -08:00
test_scheduled.rb Merge branch 'master' into frozen 2016-04-21 13:15:00 -07:00
test_scheduling.rb Fix the error in worker#perform_in about interval type (#3170) 2016-09-30 02:31:08 -07:00
test_sidekiq.rb Put source encoding comment as line for (j)ruby 1.9 compatibility (#3255) 2016-11-22 20:39:00 -08:00
test_testing.rb Fix overriding class_attribute core extension from ActiveSupport with Sidekiq one 2017-06-06 08:10:08 -07:00
test_testing_fake.rb timing is everything 2017-06-21 13:21:11 -07:00
test_testing_inline.rb Disable delay extensions by default, fixes #3174 (#3299) 2017-01-04 10:30:42 -08:00
test_util.rb Exceptions raised during the startup event should kill the process, fixes #3717 2018-01-11 09:37:55 -08:00
test_web.rb Remove percy, the Web UI doesn’t change enough to justify the complex dependency 2017-06-06 14:54:20 -07:00
test_web_helpers.rb Sorting Of Available Locales 2017-12-18 07:40:21 -08:00