简体   繁体   English

每个实例的AppDomain还是进程?

[英]AppDomain or process per instance?

I would like to know whether I should use a process per instance or whether I should run multiple instances in a single process using AppDomain s. 我想知道是否应该为每个实例使用一个进程,或者我是否应该使用AppDomain在一个进程中运行多个实例。

I have a server application which follows a design kind of like telnet. 我有一个服务器应用程序遵循设计类似telnet。 The user is always connected over TCP and the server keeps a full state of the client session which is presented on the workstation. 用户始终通过TCP连接,服务器保持工作站上显示的客户端会话的完整状态。

The software will need to support up to at least 500 concurrent connections, probably more. 该软件需要支持最多至少500个并发连接,可能更多。 A typical installation will require somewhere between 3 and 7 instances of the application to be running continuously, although all but one instance will have just a few connections (they are for testing, reference environments, etc). 典型的安装需要连续运行3到7个应用程序实例,尽管除了一个实例之外只有几个连接(它们用于测试,参考环境等)。 In house, for development purposes, there will be a maximum of 40 environments with a maximum of 20 concurrent connections per environment. 在内部,出于开发目的,每个环境最多有40个环境,最多20个并发连接。 My target host environment will be 64bit Windows. 我的目标主机环境将是64位Windows。

I know that IIS uses a model where it has just one process and multiple AppDomain s, but I can also see advantages in having a process per instance. 我知道IIS使用的模型只有一个进程和多个AppDomain ,但我也看到每个实例都有一个进程的优点。

Which should I use and why? 我应该使用哪个以及为什么?

EDIT: 编辑:
The different instances concern different versions of the same application which cannot be run in a single AppDomain together. 不同的实例涉及同一应用程序的不同版本,这些版本无法一起在单个AppDomain运行。 Also, the different instances do not have to communicate with each other, only with a master service for management purposes. 此外,不同的实例不必彼此通信,仅用于管理目的的主服务。

To sum up: 总结一下:

  1. You have a telnet like server application. 你有一个像服务器应用程序的telnet。
  2. You will have multiple versions of this application running on the same machine. 您将在同一台计算机上运行此应用程序的多个版本。
  3. The different instances do NOT need to communicate with each other; 不同的实例不需要相互通信; only with a common service. 只有共同的服务。

Presumably each instance communicates over a different port 据推测,每个实例都通过不同的端口进行通信

With those requirements I would never consider building out the same functionality that IIS has. 有了这些要求,我永远不会考虑构建与IIS相同的功能。 Instead I would run them as completely separate applications. 而是我将它们作为完全独立的应用程序运行。

BTW, you are incorrect stating that IIS only has 1 process with multiple app domains. 顺便说一句,你说错了,IIS只有1个进程有多个应用程序域。 IIS can spin up multiple processes for a single site. IIS可以为单个站点启动多个进程。 This is called a Web Garden . 这被称为Web Garden Further, IIS spins up at least one process for each Application Pool it has. 此外,IIS为其拥有的每个应用程序池至少启动一个进程。 You can see these as separate w3wp.exe processes executing on the IIS server. 您可以将这些视为在IIS服务器上执行的单独的w3wp.exe进程。

The only benefit to running everything through a common process is if the host provides something of value that is common to everything. 通过一个共同流程运行所有东西的唯一好处是,如果主机提供了一切对所有东西都有的价值。 For example a logging interface or failure handling. 例如,日志记录界面或故障处理。 This would be very complicated to write, set up, and maintain for little benefit. 编写,设置和维护对于收效甚微来说非常复杂。

Finally, the number of users is immaterial as that is going to be governed by resource usage of the application(s). 最后,用户数量并不重要,因为它将受应用程序的资源使用控制。 This might mean network, memory, or even disk depending on exactly what functions your app performs. 这可能意味着网络,内存甚至磁盘,具体取决于您的应用程序执行的功能。

well, you cant have process per user session since you plan for 500 of those. 好吧,你不能有每个用户会话的进程,因为你计划500个。 the same can be said for 500 appdomains. 500 appdomains也是如此。 IIS uses an appdomain per Application , not user session, under a host process (app pool). IIS在主机进程(应用程序池)下使用每个应用程序的应用程序域,而不是用户会话。

may i sugest you use a similar design? 我可能会使用类似的设计吗? each instance in its app domain (40 max instacse you say?) each user handled by thread with no new app domain/process creaeted.(wont sacle as pointed) to support high number of users, maybe a load balancer can be used directing to a cluster of machines 每个应用程序域中的实例(你说的最多40个实例?)每个用户都由线程处理,没有新的应用程序域/进程creaeted。(不会像指出的那样)支持大量用户,也许负载均衡器可以用于指导一群机器

It's pretty easy to structure your server so that you can decide this later, and, more likely, have a bit of a mix; 构建服务器非常容易,以便您以后可以做出决定,并且更有可能有一点混合; some shared hosting with multiple app domains and some single hosting? 一些共享主机与多个应用程序域和一些单一主机?

The complex bit isn't creating multiple app domains and running the same app multiple times. 复杂的位不会创建多个应用程序域并多次运行相同的应用程序。 The complex bit is getting to the point where you can create a single app domain and host a single app. 复杂的位置已经到了可以创建单个应用程序域并托管单个应用程序的程度。 Once you can do that, scaling out to multiple app domains with either the same or different apps is easy. 一旦您可以这样做,使用相同或不同的应用程序扩展到多个应用程序域很容易。

I have an example server ( here ) that ships as part of my server framework that can operate in both ways, it hosts a single app domain on one port and spins up a per user app domain on a second port (I'm not suggesting that a per user app domain is what you need, just that it's at the opposite end of the scale to a single app domain per server). 我有一个示例服务器( 这里 )作为我的服务器框架的一部分,可以以两种方式运行,它在一个端口上托管一个应用程序域,并在第二个端口上旋转每个用户应用程序域(我不建议)每个用户应用程序域是您所需要的,只是它在每个服务器的单个应用程序域的规模的另一端)。

There's also a new example which does the whole 'shadow copy, auto restart' thing that IIS does, this is a little more complex but I've written about it here and here . 还有一个新的例子可以完成IIS所做的整个“影子复制,自动重启”的事情,这有点复杂,但我已经在这里这里写过了。 Again it's not too complex to do once you have the basic hosting in place. 一旦你有了基本的主机,它就不会太复杂了。

Personally I tend to build all of that into a service and then simply run multiple copies if you want multiple server and then you can mix and match as you see fit and as profiling of the complete system suggests you should. 我个人倾向于将所有这些构建到服务中,然后只需要运行多个副本,如果你想要多个服务器,那么你可以根据需要混合搭配,并且整个系统的分析表明你应该这样做。

I guess, in summary, I'd say that you should design for the multiple app domain situation as you can always simply run a single app domain and multiple processes by configuring the server with a single app domain... 我想,总的来说,我会说你应该设计多个应用程序域的情况,因为你总是可以通过使用单个应用程序域配置服务器来运行单个应用程序域和多个进程...

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

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