同一应用服务中的 Azure 函数是否在同一实例中运行 [英] Do Azure Function from Same App Service Run in Same Instance

查看:30
本文介绍了同一应用服务中的 Azure 函数是否在同一实例中运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个场景,其中我的一个类有一个静态成员,我可以从函数应用程序设置其值.假设属于同一个应用服务计划的另一个函数应用也使用这个相同的类,并且还设置/依赖于静态成员的值.现在,如果这两个功能应用程序从不同时运行,我们没有问题.此外,如果它们不在同一个实例下运行,那么我们也没有问题,因为每个正在运行的实例都有自己的类定义.

I have a scenario where one of my Class has a static member whose value I can set from a Function App. Suppose another Function App belonging to same App Service Plan also uses this same class and also sets/relies on the value of the static member. Now, if the two function apps never run simultaneously, we have no issue. Also, if they don't run under same instance, then we also have no issue as each running instance will have their own definition of the class.

我的问题是,来自同一个应用服务的每个函数应用是否运行在不同的实例上?

My question is, do each Function App from same App Service run on different instance?

我了解重新设计将消除任何可能的问题,但我只是对同一应用服务中的功能应用之间的交互感到好奇.

I understand redesigning will eliminate any possible issues, but I am just curious on the interaction between Function Apps in same App Service.

推荐答案

我觉得你最好了解一下流程边界.

I think it will be better for you to understand the process boundaries.

您有一个 Azure 函数应用 (FuncApp1.azurewebsites.net),它可能在应用服务计划中托管了一个或多个函数.您提到您有另一个 Azure Function App (FuncApp2.azurewebsites.net),其中一个或多个它自己的一组功能托管在同一个应用服务计划上.这是正确的吗?

You have an Azure Function App (FuncApp1.azurewebsites.net) that may have one or more functions hosted on an App Service Plan. You're mentioning that you have another Azure Function App (FuncApp2.azurewebsites.net) with one or more of it's own set of functions hosted on the same App Service Plan. Is this correct?

FuncApp1 将在云中的某些机器上拥有自己的进程 ID、内存/cpu 消耗和线程,而 FuncApp2 也是如此.静态成员基本上独立存在于两个独立的程序中.在您的函数应用可能横向扩展的情况下,每个新实例很可能都有自己的进程 ID 等.

FuncApp1 will have it's own process id, memory/cpu consumption, and threads on some machine in the cloud and the same for FuncApp2. The static member basically exists independently in two separate programs. In the case where your function app may scale out, each new instance will most likely have it's own process id, etc.

所以NO你的函数应用不会互相踩踏.您唯一关心的应该是静态成员在同一进程 ID 中是否是线程安全的.在什么情况下,您依赖可以根据请求更改的静态成员?一些递增的 ID?

So NO your function apps will not step on each other. Your only concern should be if the static member is thread safe within the same process id. In what scenario are you relying on a static member that may be altered per request? Some incrementing ID?

这篇关于同一应用服务中的 Azure 函数是否在同一实例中运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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