I want to schedule periodic jobs, and I want to deploy multiple Sidekiq processes for increased throughput. I imagine this means multiple containers running bundle exec sidekiq
(or sidekiqswarm
), each invoking their Sidekiq initializer when they start up. The initializer would contain something like:
Sidekiq.configure_server do |config|
config.periodic do |mgr|
mgr.register("* 4 * * *", "MyJob")
mgr.register("* 4 * * *", "MyOtherJob")
...
I'm hoping Sidekiq will be smart enough to recognize that each process is registering the same things and not duplicate them? But what if I later redeploy with an updated configuration:
mgr.register("* 4 * * *", "MyBetterJob")
mgr.register("* 5 * * *", "MyOtherJob")
Will I now have MyJob and MyBetterJob both running at 4, and MyOtherJob running at 4 and 5? How do I clean out the old crons? This seems like a maintainance headache. How do I just declare the desired current set of cron jobs?
I found this answer suggesting clearing out crons by deleting keys in Redis, but having multiple processes each doing that at once would be a mess. Is embedding the cron management within an actor on the leader the recommended practice?