Azure Functions 计时器触发器横向扩展 [英] Azure Functions Timer Trigger Scale-out

查看:21
本文介绍了Azure Functions 计时器触发器横向扩展的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我有一个每 5 分钟在计时器触发器上运行的 Azure 函数,如果一个 运行 需要超过 5 分钟会发生什么?

If i have an Azure Function which runs on a timer trigger every 5 minutes, what happens if one run takes more than 5 minutes?

无论当前是否有任何正在执行的触发器,下一个计时器触发器都会启动吗?

Will the next timer trigger kick off, regardless of any currently executing triggers?

我问的原因:我需要确保一次只运行 1 个 Azure 函数(是的,我知道这种做法违背了函数的概念).如果一次运行需要 <5 分钟(大部分时间应该如此),太棒了 - 在下一个 5 分钟窗口开始下一个.如果没有完成,请不要开始.

Reason i ask: I need to ensure only 1 Azure Function is running at a time (yes, i know this kind of goes against the concept of functions). If one run takes < 5 minutes (most of the time it should), great - kick off next one at the next 5 minute window. If it doesn't finish, don't kick off.

我更喜欢使用 Azure Functions,但在这种情况下 - 我应该不打扰并简单地使用持续运行的 Azure WebJob 来代替吗?

I'd prefer to use Azure Functions, but in this case - should i just not bother and simply use a continuously running Azure WebJob instead?

谢谢!

推荐答案

如 TimerTrigger 中所述 维基页面:

As described in the TimerTrigger wiki page:

如果您的函数执行时间超过计时器间隔,则在当前调用完成之前不会触发另一个执行.在当前执行完成后安排下一次执行.

If your function execution takes longer than the timer interval, another execution won't be triggered until after the current invocation completes. The next execution is scheduled after the current execution completes.

所以您应该已经获得了您正在寻找的行为 - 在任何给定时间只运行一个函数调用.

So you should be getting the behavior you're looking for already - only a single function invocation running at any given time.

这篇关于Azure Functions 计时器触发器横向扩展的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆