单身缩放 [英] Scaling singletons

查看:194
本文介绍了单身缩放的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有一些困难的时间思索一些体系结构问题对我的基于服务器的应用程序后,我觉得我将不得不使用单身来完成我的目标。纯粹是出于以下原因(我辩解闻):

After having some difficult hours mulling over some architecture issues for my server-based application, I feel I am going to have to use singletons to accomplish my goal. Purely for the following reasons (justifying my smell):


  • 我不需要昂贵的物品通过深入调用堆栈

  • 我可以在任何上下文中的单管理对象履行职责。 (很多代码已经存在,所以我不愿重写,否则工作代码广泛块)

除此之外,单身建议的另一个问题。我的基于服务器的应用程序基本上是与可以调用服务器的多个实例的类的DLL。服务器实例类包含单管理对象。通常情况下,这将通过Windows服务来管理,因此服务器:机比例为1:1。

Apart from that, Singletons suggest another problem. My server-based application is essentially a DLL with a class that can invoke multiple instances of servers. The server instance class contains the singleton management objects. Ordinarily, this would be managed by a Windows Service, so server:machine ratio will be 1:1.

所以,你可以把它看作(其中 - >为1: 1,=>为1:许多):

So you could view it as (where -> is 1:1, => is 1:many):

机 - >的ServiceHost(Windows服务) - > Server实例 - >辛格尔顿管理对象

MACHINE -> ServiceHost (Windows service?) -> Server instance -> Singleton management objects

不过,我们要允许一个SaaS模式,这就需要服务的主机(无论是Windows服务或Win32应用程序)所要求的企业要能够火起来的多台服务器。因此,一个物理机可以运行在一台服务器主机,该主机可以运行多个服务器实例

However, we would like to allow for an SaaS model, which would require a service host (be it a Windows Service or Win32 application) to be able to fire up multiple servers as required by the business. Therefore, a physical machine could run a single server host, which would run multiple server instances.

这将是(其中 - >为1:1,=>是1 :很多):

Which would be (where -> is 1:1, => is 1:many):

机 - >的ServiceHost(Windows服务)的 => 服务器实例 - >的辛格尔顿管理对象

MACHINE -> ServiceHost (Windows service?) => Server instance -> Singleton management objects

的问题是,这些单件将在服务器之间共享。这不可能发生。单身必须是1:1的服务器实例

The problem is that these singletons would be shared across servers. Which cannot happen. The singletons must be 1:1 with the server instance.

假如我不能从这些单身移开,是否有可能对我来说,这些服务器实例从相互分离调用服务实例类作为一个单独的进程/内存空间?

Assuming I cannot move away from these singletons, is it possible for me to separate these server instances from each other by invoking the service instance class as a separate process/memory space?

我只能想象,我需要火了多个EXE文件(anduse WCF管理),一个用于每个服务器实例。这显然不是很好。

I can only imagine that I would need to fire up multiple EXEs (anduse WCF to manage), one for each server instance. This would obviously not be very good.

推荐答案

对不同应用程序域为不同的实例?

What about different AppDomains for different "Instances"?

这篇关于单身缩放的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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