Reputation: 85
I want to use cron module (later, node-cron etc.) in my node server to schedule jobs. The jobs are notifications (eg. email) sent to a user to update his profile picture if he hasen't done so after 1 hour of signup. I am using later
module to schedule tasks when user signs up, to be executed 1 hour after to check whether he has uploaded profile picture, and send notification if not. My questions are:
1. Will having a large number of scheduled jobs affect server performance?
2. What is the best way to schedule large number of jobs without affecting the system performance?
Upvotes: 2
Views: 3082
Reputation: 36329
It's hard to say whether a large number will affect system performance, since it depends an aweful lot on what they're doing and how they're doing it, as well as how many end up hitting at one time, etc.
That said, my opinion is that using this sort of thing for managing the sorts of things you're describing will severely limit your scalability, as each one is scoped to the application instance (so if you want to scale horizontally, each manages they're own; if one crashes w/o sending notifications out, what happens? etc).
I think you're far better off using some kind of distributed task manager, based perhaps on a Redis queue or similar. Your web app posts jobs to that, and a separate process or processes can handle running tasks when they expire. There's a few modules for this sort of thing, kue
is the one I've played with.
Upvotes: 2