Valkey: Configuring Valkey with Sidekiq
This documentation is part of the Using with Ruby guide. You can view the complete guide here: How to connect Valkey with Ruby.
👋 Welcome to the Stackhero documentation!
Stackhero offers a ready-to-use Valkey cloud solution that provides a host of benefits, including:
Redis Commanderweb UI included.- Unlimited message size and transfers.
- Effortless updates with just a click.
- Optimal performance and robust security powered by a private and dedicated VM.
Save time and simplify your life: it only takes 5 minutes to try Stackhero's Valkey cloud hosting solution!
Sidekiq will automatically use the Valkey server defined by the environment variable REDIS_URL.
You can set the environment variable REDIS_URL like this, just replacing <password> and <XXXXXX> with your information:
REDIS_URL="rediss://default:<password>@<XXXXXX>.stackhero-network.com:<PORT_TLS>"
By default, Sidekiq is configured in a manner that does not accommodate any tolerance during network disturbances. To improve this, we suggest modifying the Sidekiq client configuration in config/initializers/sidekiq.rb to enhance stability:
# File config/initializers/sidekiq.rb
Sidekiq.configure_client do |config|
config.redis = {
network_timeout: 5, # Set the timeout to 5 seconds
pool_timeout: 5, # Set the timeout to 5 seconds
reconnect_attempts: Array.new(240, 0.5) # Try to reconnect 240 times, every 0.5 second (120 seconds/2 minutes in total) before triggering an error
}
end
This configuration ensures that if your Valkey server becomes unavailable, the client will attempt retries for a duration of 2 minutes before reporting an error. This gives the Valkey server time to restart, for example. Depending on your Sidekiq's usage, you may adjust this setting to better suit your specific requirements.
For more information about Sidekiq and Valkey, you can consult the official documentation here.