Sidekiq Configuration for Multiple Environments

Sidekiq deploy to multiple environments

In your initializers/sidekiq.rb file, you specify the Redis queue all environments boot up with.
For mine it is:

redisServer = "localhost"
Sidekiq.configure_server do |config|
config.redis = { :url => 'redis://' + redisServer + ':6379/0' }
end

If you want each environment to process from separate queues, you can have specific sidekiq.rb files in the environments folder for each environment. Each with different redis servers.

Specify environment specific configuration with Sidekiq and plain Ruby

To support multiple environments in sidekiq - look at this: Sidekiq configuration for multiple environments

For your specific question - how to implement initializers in pure ruby, you can put them anywhere you want, but you need to require them in your main file.

If you want to be a little more sophisticated (or you have a lot of initializers), you can require all of them under a folder (initializers/ for example), and then require anything under that folder:

Dir["/initializers/*.rb"].each {|file| require file }

How can I specify different concurrency queues for sidekiq configuration?

Concurrency is a property of the Sidekiq process, representing how many threads it spins up. You can't have one Sidekiq process operating at two different concurrencies; however, you could spin up two Sidekiq processes with separate config files:

bin/sidekiq -C config/sidekiq_one.yml
bin/sidekiq -C config/sidekiq_two.yml

However, depending on your motivations here, you're likely better off just using one Sidekiq process and ordering your queues within it by priority. That way, no workers in one process are sitting idle while the other process's queue is growing. Though depending on your situation, e.g. if the second queue's jobs are few but very important, such a solution does make sense.



Related Topics



Leave a reply



Submit