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

26 commits

Author SHA1 Message Date
Tobias Bühlmann
da3fbed14b Use redis' default driver (#3956)
Redis stores its loaded drivers in `Redis::Connection.drivers` and uses the
last one of them when initializing a new client. Sidekiq always uses `'ruby'`
(or `Redis::Connection::Ruby`) per default, though.

With this commit we are following redis' default by passing the last
loaded driver per default (or a given `:driver`).
2018-09-09 06:11:37 -07:00
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
Jeremy Daer
6332b9f8a3 redis-rb 4.0 support
* Loosen Redis version dep to `>= 3.3.5, < 5`
* Bump redis-namespace for looser Redis version dep. Pending
  https://github.com/resque/redis-namespace/pull/136 gem release.

Use `redis.connection` where we can and fall back to `redis._client`
where we need (to inspect timeout and scheme).

References #3617
2017-09-28 21:54:06 -07:00
Mike Perham
33846c849a Allow users to disable ID generation since some redis providers disable the CLIENT command, fixes #3521 2017-06-21 04:54:18 -07:00
Mike Perham
980438c61d Add default Redis client identifier, #3516 2017-06-16 08:40:43 -07:00
Christopher Louvet
9d09539eba Symbolize keys in options hash for RedisConnection.create
Fixes an edge case where a stringified `namespace` key
is ignored. A `namespace` key may be a string if
the Sidekiq Redis config is loaded from a yml file.

Also minor, syntactical improvements to error messaging.

Existing tests pass. Added a new test to address
this edge-case.
2016-05-26 12:50:37 +07:00
Mike Perham
2c9f7662fc Freeze all string literals in source, fixes #2741
Tests pass and smoke test works perfectly.
2015-12-31 15:33:35 -08:00
Mike Perham
53e6b9e2df Test suite overhaul
Remove Redis mocking.  Minimize Redis flushing where possible.
2015-09-23 10:56:37 -07:00
grosser
57a06d00d6 allow every test to be run with just ruby test/xxx_test.rb 2014-12-30 12:54:58 -08:00
Charlie Somerville
f920fbc0ed use ENV.to_hash instead of ENV.to_h to support antique rubies 2014-06-08 13:53:47 +10:00
Charlie Somerville
925b80e85e restore env vars to original values after these tests 2014-06-08 13:43:22 +10:00
Mike Perham
7d2b387d94 merge 2.17.5 stuff 2014-02-15 23:49:56 -08:00
Sean Doyle
e12bf878fa Replaced class and instance level send
Replaced with `__send__` from std lib

* `send` can now be overridden to be more semantically meaningful
  * `message.send(user_id)` as opposed to `message.send_message(user_id)`
* `__send__` makes it clear that the reflective version is intended
2014-02-14 09:43:34 -05:00
Mike Perham
44379c8d48 Fix test 2014-02-01 21:14:32 -08:00
Chris Sprehe
da48ce6ded changed #determine_redis_provider to first check against the REDIS_PROVIDER env variable 2013-11-24 08:16:37 -06:00
Salimane Adjao Moustapha
ceb7b9a7d4 add socket path test cases 2013-10-21 21:54:02 +02:00
Mike Perham
babfdc96c5 Backport test suite to Minitest 4 so we can test against Rails 4. 2013-09-22 14:38:33 -07:00
Glen
48c70f8545 Added option to set the network timeout for the Redis connection 2013-07-17 09:02:51 -06:00
Glen
5a4de159f0 Allow setting of a custom timeout for the Redis Connection Pool 2013-07-16 15:40:50 -06:00
Mike Perham
4679c95f49 Upgrade to Minitest 5 2013-05-12 14:25:30 -07:00
Mike Perham
6961a4f20f Refactor redis log to print in both server and client 2013-04-17 10:07:46 -07:00
Mike Perham
a129a444fd Lock down namespace configuration, fixes #747 2013-03-01 16:13:20 -08:00
Brandon Hilkert
396bf6cd7a Move global Sidekiq option changes to before/after when testing redis
connection so it doesn't pollute the rest of the test suite.
2013-01-26 16:17:27 -05:00
Mike Perham
00af937b8f Fix broken tests due to #631 changing global state 2013-01-26 08:07:13 -08:00
grosser
e43d46aa4d use namespace from options/config 2013-01-19 16:03:12 -08:00
jc00ke
619176f92d Refactor & add tests for determine_redis_provider 2012-10-14 16:12:17 -07:00