Skip to content

Commit

Permalink
Reduce the time window for Sidekiq retries
Browse files Browse the repository at this point in the history
The previous code meant that if there was a Sidekiq connection error
there would be a `sleep(15)` called before any attempt to reconnect to
Redis. For a client application serving a web request and adding to the
Sidekiq this 15 seconds is a very long time to wait.

This is substantially longer than the gem default values which are a
0.25s wait twice [1]

The motivation for making this change was finding that in a Heroku
environment (which we are currently using for demoing an app) it is
frequent that we receive an intermittment 15 second wait to serve a
request. The Redis connection must be less reliable on the cheaper
hardware.

[1]: https://github.com/redis-rb/redis-client/blob/8dfe1f65208482bb30150dd0009254ac77fe4776/lib/redis_client/sentinel_config.rb#L7-L8
  • Loading branch information
kevindew committed Jan 23, 2025
1 parent 0d3a64c commit 6fe2f87
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog


* Reduce Redis reconnection timeout from 15-60s to 0.05-5s

## 9.0.3

* Update dependencies
Expand Down
2 changes: 1 addition & 1 deletion lib/govuk_sidekiq/sidekiq_initializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
module GovukSidekiq
module SidekiqInitializer
def self.setup_sidekiq(redis_config = {})
redis_config = redis_config.merge(reconnect_attempts: [15, 30, 45, 60])
redis_config = redis_config.merge(reconnect_attempts: [0.05, 0.25, 1, 5])

Sidekiq.configure_server do |config|
# $real_stdout is defined by govuk_app_config and is used to point to
Expand Down

0 comments on commit 6fe2f87

Please sign in to comment.