Reputation: 9664
If I want to schedule a task to run say once every 30 minutes. I could do this with a basic timeout or use a node module like node-schedule.
But If I deploy my app to the cloud, such as Amazon AWS or Azure, and scale the instances to say 10, will this task then be scheduled to run 10 times, one for each instance? How can I avoid this, or am I thinking about how cloud instanced work in the wrong way.
Upvotes: 0
Views: 1125
Reputation: 500
If you want to use an Azure component, you could use the Azure scheduler:
Create jobs that run on your schedule Azure Scheduler lets you create jobs in the cloud that reliably invoke services inside and outside of Azure—such as calling HTTP/S endpoints or posting messages to Azure Storage queues. You can choose to run jobs right away, on a recurring schedule, or at some point in the future.
Upvotes: 1
Reputation: 7550
It entirely depends on your code but I'd imagine that yes it will run on each instance, probably slightly out of sync too.
This article describes quite nicely the problems with scheduled tasks:
http://dejanglozic.com/2014/07/21/node-js-apps-and-periodic-tasks/
My advice would be to try and avoid scheduled tasks as much as possible.
Upvotes: 0