0
votes

I have a Django app running on Heroku and I need to run background tasks every hour. It's quite important that I don't miss an event

I know I can use the Heroku scheduler. However, it says:

Scheduler is a “best effort” service, meaning that execution is expected but not guaranteed. Scheduler is known to occasionally (but rarely) miss the execution of scheduled jobs. If scheduled jobs are a critical component of your application, it is recommended to run a custom clock process instead for more reliability, control, and visibility.

Since I don't want to miss event, I went to the custom clock process page and there it says:

Since dynos are restarted at least once a day some logic will need to exist on startup of the clock process to ensure that a job interval wasn’t skipped during the dyno restart.

So my question is, is there an advantage to using a clock process vs the Heroku scheduler apart from being more flexible regarding times it should run? Since neither is 100% reliable I rather use the scheduler and implement some logic to make sure it gets run otherwise I have to pay for an extra dyno (the clock process).

1

1 Answers

1
votes

Yes there are some! But as you already said, the main and most prominent difference of using a clock process, is the much finer level of granularity you can achieve. With the Heroku Scheduler, for example, you cannot achieve things like:

  1. Run every 5 minutes
  2. Run every 10 seconds

That being said another important difference between the two scheduling methods is reliability. When you use the Heroku Scheduler you are literally using a "black box", with no control over the size of your infrastructure. With a clock process you are one step further, as you can choose the size of your dyno (maybe you have a scheduling process that demands some kind of hard computation (even though you'll better dispatch the computational demanding tasks to background workers)).

Also, one could argue, if you have a complex scheduling system that calls many different external services and scripts, having control over the scheduling code may help you testing and organizing your code.