registry icon indicating copy to clipboard operation
registry copied to clipboard

Sidekiq: setup db storage

Open vohmar opened this issue 4 years ago • 2 comments

Sidekiq runs on in-memory redis database. As we have scheduled tasks that are planned for days ahead we need a solution to preserve the tasks so that redis server restart would not wipe the list clean.

Implement storage layer for storing tasks scheduled to run and possibly load jobs to redis memory only if the task is planned to run within 24 hrs

Related to: https://github.com/internetee/registry/issues/1954

vohmar avatar Apr 27 '21 09:04 vohmar

Looks like we don't need to.

According to Sidekiq documentation

By default, Sidekiq 6+ gives workers 25 seconds to shut down. (Run Sidekiq <6 with -t 25.) This is carefully chosen because Heroku and AWS ECS give a process 30 seconds to shutdown before killing it. After 25 seconds, any remaining jobs still in progress are pushed back onto Redis so they can be immediately restarted when Sidekiq starts back up. Remember that Sidekiq will run your jobs AT LEAST once so they need to be idempotent. This is one example of how a job can be run twice.

Tried that on staging - scheduled manually an whois update job one week ahead, restarted Redis service from shell console, redeployed application as a whole. Job persists as a scheduled.

yulgolem avatar Apr 27 '21 09:04 yulgolem

As well I suppose we should implement some Redis-side persistence mechanisms as per https://redis.io/topics/persistence

yulgolem avatar Apr 27 '21 09:04 yulgolem