Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

configure multiple server to support sidekiq

I planned to migrate redis server to a new one with sidekiq running, but doesn't want to stop the current application running. And I don't want to use redis cluster which is still alpha version. My thought is to ask sidekiq to write to new redis server, but pulls from both of them, so that once the workers in old redis are completed, the new one can totally take over all workers. I think this solution is feasible, but I have no idea how to make it happen.

This is my sidekiq.rb:

sidkiq_config = YAML.load(ERB.new(Rails.root.join('config/redis.yml').read).result)

Sidekiq.configure_server do |config|
  config.logger.level = Logger::ERROR
  config.redis = { :url => "redis://redis2.staging:6379", :namespace => "app_#{Rails.env}:sidekiq" }
  config.redis = { :url => "redis://redis.staging:6379", :namespace => "app_#{Rails.env}:sidekiq" }
end

Sidekiq.configure_client do |config|
  config.logger.level = Logger::ERROR
  config.redis = { :url => "redis://redis2.staging:6379", :namespace => "app_#{Rails.env}:sidekiq" }
end
like image 727
Sebastien Liu Avatar asked Dec 15 '25 13:12

Sebastien Liu


1 Answers

I believe the easiest solution is to run two instances of sidekiq - one that reads from the old cluster, and one that reads from the new cluster

sidkiq_config = YAML.load(ERB.new(Rails.root.join('config/redis.yml').read).result)

Sidekiq.configure_server do |config|
  config.logger.level = Logger::ERROR
  if ENV['read_from_new']
    config.redis = { :url => "redis://redis2.staging:6379", :namespace => "app_#{Rails.env}:sidekiq" }
  else 
    config.redis = { :url => "redis://redis.staging:6379", :namespace => "app_#{Rails.env}:sidekiq" }
  end
end

Sidekiq.configure_client do |config|
  config.logger.level = Logger::ERROR
  config.redis = { :url => "redis://redis2.staging:6379", :namespace => "app_#{Rails.env}:sidekiq" }
end
like image 53
Uri Agassi Avatar answered Dec 18 '25 05:12

Uri Agassi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!