简体   繁体   English

具有Singleton类的Azure Auto Scaling

[英]Azure Auto Scaling with a Singleton Class

Azure has this setting that you can Auto Scale running Instances of your Web app depending how big the current load is. Azure具有此设置,您可以根据当前负载的大小自动缩放Web应用程序的运行实例。

My question is what happens if you have a Singleton Class and run Multiple Instances, will this class exist once per Instance? 我的问题是,如果您有一个Singleton类并运行多个实例,该类每个实例是否存在一次会发生什么? From my understating each Instance will have the Singleton Class initialized, is this correct? 根据我的低估,每个实例都会初始化Singleton类,这是正确的吗?

Each 'instance' is really just another virtual machine running your web app. 每个“实例”实际上只是运行您的Web应用程序的另一个虚拟机。 Hence, each will have its own application pool, memory space, and IIS worker process handling its traffic for your web app. 因此,每个应用程序都有自己的应用程序池,内存空间和IIS工作进程,以处理其Web应用程序的流量。

Since a singleton runs in its own application space on each of these instances (VMs) you will get one singleton for each 'instance'. 由于单例在每个这些实例(VM)上在其自己的应用程序空间中运行,因此您将为每个“实例”获得一个单例。

If you are interested in creating instances of objects that transcend their memory location check out the Actor Pattern, project Orleans and the new Azure Service Fabric. 如果您对创建超出其内存位置的对象实例感兴趣,请查看Actor模式,项目Orleans和新的Azure Service Fabric。 These technologies are implementations of the Actor pattern and allow you to create an object that is agnostic to the physical infrastructure it runs on. 这些技术是Actor模式的实现,使您可以创建与其运行的物理基础结构无关的对象。

If you are just interested in sharing state between multiple instances of your web app, check out Redis cache as a high performant way to create a shared pool of data between web apps. 如果您只想在Web应用程序的多个实例之间共享状态,请查看Redis缓存,这是在Web应用程序之间创建共享数据池的高性能方法。

每个网络/工作者实例将有一个Singleton实例。

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

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