Sidekiq works pretty well with standard redis client. This is an example of configuring it (from official wiki):
12345678
Sidekiq.configure_serverdo|config|config.redis={:url=>'redis://redis.example.com:7372/12',:namespace=>'mynamespace'}end# When in Unicorn, this block needs to go in unicorn's `after_fork` callback:Sidekiq.configure_clientdo|config|config.redis={:url=>'redis://redis.example.com:7372/12',:namespace=>'mynamespace'}end
But, what if you need a special redis client that can’t be initialized with redis URL? No worries. Setter for Sidekiq#redis also accepts a ConnectionPool. Here we have full control over how we initialize our redis client. Here’s how you may initialize Sidekiq with a bunch of RedisFailover clients:
12345678910
Sidekiq.configure_serverdo|config|pool=ConnectionPool.new(:size=>10,:timeout=>3)dozkservers='localhost:2181,localhost:2182,localhost:2183'RedisFailover::Client.newnamespace:'my_service',zkservers:zkserversendconfig.redis=poolend# do the same in Sidekiq.configure_client
You can even read Sidekiq’s concurrency setting and pass it to the connection pool initializer. Now your sidekiq farm doesn’t care about redis crashes :)