I am currently using nodejs and agenda to run cronjobs. Currently, there are 10 cronjobs and since node is single threaded it's taking a longer time for each of them to be done when all of them run simultaneously.
I have tried pm2 by running the command pm2 start app.js -i max
with which each job is running as many cores are available.
As an example, I am calling a function once the node process starts, the same function is called 8 times (there are 8 cores on my server). The same is happening when I do using npm cluster.
How can I use multiple cores of the CPU using pm2 or npm's cluster mode from here https://nodejs.org/api/cluster.html so that each of the cronjob would run on different processor?
Please advise!