azure - 频繁触发的 CRON Azure Web 作业在运行时间超过配置的频率时是否会被第二次触发

标签 azure cron azure-webjobs

假设每五分钟通过 CRON 触发一次作业。由于某种原因,10:00 的一次执行持续时间明显更长,例如8分钟。第二个实例是否在 10:05 触发?

如果是,确保作业作为单例运行并且不会运行两次的正确策略是什么?

最佳答案

我自己还没有测试过,但来自docs我可以找到那句话

If you use a schedule-driven task that must run as a single instance, be aware of the following:

  • If the compute instance that is running the scheduler (such as a virtual machine using Windows scheduled tasks) is scaled, you will have multiple instances of the scheduler running. These could start multiple instances of the task.
  • If tasks run for longer than the period between scheduler events, the scheduler may start another instance of the task while the previous one is still running.

this 中的文档中也提到了可能的解决方案部分

By default, WebJobs scale with their associated Azure Web Apps instance. However, if you want a WebJob to run as only a single instance, you can create a Settings.job file that contains the JSON data { "is_singleton": true }. This forces Azure to only run one instance of the WebJob, even if there are multiple instances of the associated web app. This can be a useful technique for scheduled jobs that must run as only a single instance.

that部分

By default, WebJobs scale with the web app. However, you can configure jobs to run on single instance by setting the is_singleton configuration property to true. Single instance WebJobs are useful for tasks that you do not want to scale or run as simultaneous multiple instances, such as reindexing, data analysis, and similar tasks.

关于azure - 频繁触发的 CRON Azure Web 作业在运行时间超过配置的频率时是否会被第二次触发,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39675434/

相关文章:

visual-studio-2010 - Visual Studio 数据库项目和 SQL Azure

java - 从 Java 批量导入时覆盖 Azure Cosmos DB 中已存在的项目

java - Cron 表达式每 2 天一次

c# - 如何从Azure WebJob读取站点的web.config文件?

azure - 无法包围 Azure 管道变量中的第一个串联字符串

laravel - 无法让 laravel 在 Azure Web App Linux 上运行

python - 尝试运行 crontab

linux - 是否有任何包含 Cronjob 列表的文件?

azure - Azure 应用服务中的 .NET Core WebJob 配置

azure - 我们如何在 AZURE 中安排自定义代码调用认知 API