Scheduled Task on all instance with Auto-Scaling
In the documentation for Scheduled Tasks, it says that in an auto-scaling scenario, a random instance will be selected when the task is run or on the specific instance when manually run. I am trying to figure out if there is a way to run a scheduled task at the same time on all instances. This would is necessary if I want to perform some sort of task that interacts with the filesystem such as rebuilding a search index or moving files around. If there were to be a way to force tasks to run on all instances, this would be very helpful.
Thanks!
Environment
- Xperience by Kentico version: 30.4.1
- .NET version: 8
- Execution environment: Private cloud (Virtual machine)
- https://docs.kentico.com/developers-and-admins/customization/scheduled-tasks
Answers
Scheduled tasks are for short-lived, recurring operations that don't require manual intervention. Can you use them for other things? Yes, but you will begin to fight against their design.
What you are trying to do is what the web farm tasks API is for, not scheduled tasks.
You want to generate a web farm task in one application instance and then process it in the others, which are all synchronized through the database.
Lucene search indexes aside, you should avoid manipulating files on the file system and instead use something like Azure Blob Storage which is shared by all application instances.
To answer this question, you have to login first.