Search code examples
ruby-on-railsrubyherokusidekiq

Will Heroku dyno daily restart affect multi-day sidekiq job?


I have an app with long-running processes that transfer large amounts of data. Some of these runs can take multiple days.

I'd love to be able to run these processes in a sidekiq job with a dedicated queue, but it's not clear from Heroku's docs if daily dyno restarts will interrupt the job.

Specifically this page mentions that dynos support graceful restarts to allow them to finish processing incoming requests. Does that also apply to sidekiq workers that are still running a job?


Solution

  • Yes, they will. What you should do is chunk your job and make it idempotent where it can resume.

    The workers will receive SIGINT signal that you can listen for, depending on your job queue you are using. You will have 30 seconds from the time that signal is issued until it gets SIGKILL and you will not be able to gracefully shut down.

    There is no way to avoid the 24 hour restart, but what some people I have heard do (if you're not able to shut down within 30 seconds) is every 6 hours or so, restart your own server programmatically so it only restarts at expected times.