简体   繁体   English

Azure功能性能和依赖性注入

[英]Azure Functions Performance and Dependancy Injection

I have been looking at Azure functions with vs 2017 from Performance improvement point of view. 从性能改进的角度来看,我一直在关注vs 2017的Azure功能。 Dependency injection is something that's not currently supported by azure function. 依赖注入是azure函数当前不支持的。 But if we use workaround (something like this https://blog.wille-zone.de/post/azure-functions-proper-dependency-injection/ ) and perform dependancy injection from Static Construction of a function, what impact does it have on performance? 但是,如果我们使用变通方法(类似于https://blog.wille-zone.de/post/azure-functions-proper-dependency-injection/ )并执行函数的静态构造的依赖注入,它会产生什么影响在表现? Especially with two hosting plans. 特别是有两个托管计划。

1)Consumption Plan: If I understand correctly, it is possible that every request is seperate and will create a new host in this plan. 1)消费计划:如果我理解正确,可能每个请求都是单独的,并将在此计划中创建一个新主机。 Does this mean, that every time static constructor will be called? 这是否意味着每次都会调用静态构造函数? and make all objects instantiate again? 并使所有对象再次实例化? in that case, should dependency injection be avoided for Consumption Plan? 在这种情况下,消费计划应该避免依赖注入吗?

2)App Service Plan: This will have a dedicated vm on which Function will run, and provided "Always On" will be enabled, function will only be initiated once . 2)应用服务计划:这将有一个专用的vm,功能将在其上运行,如果启用“Always On”,功能将仅启动一次。 In this case , does dependency injection make more sense? 在这种情况下,依赖注入是否更有意义? or still the function will exit context once trigger is complete, and every time new instances will be created? 或者,一旦触发完成,该函数将退出上下文,并且每次创建新实例时?

I couldn't find a proper explanation about this possibility(if at all it's a possibility) . 我无法找到关于这种可能性的正确解释(如果可能的话)。 anyone has an idea? 有人有想法吗?

Consumption Plan doesn't mean that you will get a new host on every request. 消费计划并不意味着您将在每次请求时获得新主机。 The existing hosts will be reused for subsequent requests unless a) they are too busy, scale out kicks in and you get a new host, or b) there are no requests for several minutes, and your only host gets recycled. 现有的主机将被重复用于后续请求,除非a)它们太忙,扩展并且你得到一个新的主机,或者b)没有几分钟的请求,并且你唯一的主机被回收。

Overall, I don't see such dependency injection to be a bottleneck in most scenarios. 总的来说,在大多数情况下,我没有看到这种依赖注入成为瓶颈。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM