【Azure Function & Application Insights】在Azure Function的日志中,发现DrainMode mode enabled Traces。它是什么意思呢? - LuBu0505/My-Code GitHub Wiki

问题描述

Applicaiton Insights收集了Azure Function的日志,定期发现有” DrainMode mode enabled Traces“。 image.png

DrainMode 是什么意思呢? image.png

问题解答

排出模式(Drain mode) 属于Function App 缩放机制中的一部分,当后台检测到Function App请求量不再需要当前的instance时会停止对该instance 的监听并额外等待一段时间使当前instance 上正在执行的请求完成执行,等待时间结束后就会移除当前的instance。所以这个操作的日志被Application Insights记录为DrainMode mode enabled traces.

该机制属于平台层面的一部分, 官方文档中有提到:  

Scale-in behaviors

Event-driven scaling automatically reduces capacity when demand for your functions is reduced.

对函数的需求减少时,事件驱动的缩放会自动减少容量。

It does this by draining instances of their current function executions and then removes those instances. This behavior is logged as drain mode.

它通过清空其当前函数执行的实例,然后删除这些实例来执行此操作。 系统会将此行为记录为排出模式

The grace period for functions that are currently executing can extend up to 10 minutes for Consumption plan apps and up to 60 minutes for Premium plan apps. Event-driven scaling and this behavior don't apply to Dedicated plan apps.

当前正在执行的函数的宽限期可以扩展到消耗计划应用最多 10 分钟,高级版计划应用最多可以延长 60 分钟。 事件驱动的缩放和此行为不适用于专用计划应用。

参考资料

Azure Functions 中的事件驱动缩放  : https://learn.microsoft.com/zh-cn/azure/azure-functions/event-driven-scaling?tabs=azure-cli#scale-in-behaviors

[END]

当在复杂的环境中面临问题,格物之道需:浊而静之徐清,安以动之徐生。 云中,恰是如此!