I have a node app running on Heroku.
I want some jobs to run periodically every few seconds, in order to fetch data from an external MySQL DB to my MongoDB.
After extensive search I have found a lot of ways to do this.
My problem is I cannot fully understand the difference between cron-module and the Heroku Scheduler and the pros and cons.
Some differences I spotted:
If I use Heroku Scheduler there is a limit of 10 minutes minimum.
If I use node-cron module, I will run it in my main index.js file and it will run every few seconds if I want it to.
But how are those two methods affected when running multiple dynos?
In which case the scripts will run multiple duplicated times?
node-cron will run the function at the time specified within the instance of your app that is currently running. You can schedule these with much greater precision.
Heroku Scheduler will spin up a new dyno and run the function. Once the function finishes, the dyno will spin down (i.e. shut down). You can schedule these with less precision.
If you're using multiple dynos:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With