简体   繁体   English

c#:具有多个应用程序域的单个进程VS多个进程

[英]c# : single process with multiple app domain VS multiple process

I am currently having multiple process. 我目前有多个流程。 All of them are doing different task. 他们都在做不同的任务。 Some of them also hosts WCF services and interacting with database. 其中一些还托管WCF服务并与数据库进行交互。 Most of them are multi threaded process doing some heavy duty. 它们大多数是多线程过程,需要承担一些重任。 All of them need to up all the time (they all together act as server). 它们都需要一直保持运行状态(它们共同充当服务器)。 Some process also interact with unmanaged code through CLI. 某些进程还会通过CLI与非托管代码进行交互。

Recently i came across "single process with multiple app domain" concept. 最近,我遇到了“具有多个应用程序域的单一过程”的概念。 I am wondering is it any good in my case? 我想知道我的情况有什么好处吗? what are the limitations and advantage of this over multi process architecture ? 与多流程体系结构相比,此方法的局限性和优势是什么?

Edit: If any process crashes then it has to restart again. 编辑:如果任何进程崩溃,则必须再次重新启动。 currently there is a process watcher for that. 目前,有一个过程监视程序。

tldr : You have native dependencies. tldr :您具有本地依赖性。 Keep using separate processes if you need robustness. 如果需要鲁棒性,请继续使用单独的过程。

In my opininion, it mostly depends if you're running pure .Net code, or if you have native dependencies: Process isolation will prevent a global failure in case of a native crash (which could take down the whole process). 在我看来,这主要取决于您运行的是纯.Net代码还是具有本机依赖项:进程隔离将在发生本机崩溃的情况下防止全局故障(这可能会使整个过程崩溃)。

Same thing for unmanaged resouces: If you have an unmanaged resource leak somewhere, restarting a process "fixes" the leak. 对于非托管资源,同样的事情:如果某个地方存在非托管资源泄漏,则重新启动进程可以“修复”该泄漏。 But restarting an appdomain does not. 但是,重新启动appdomain不会。

If you're only using managed code only (which does not seems to be your case), a single process with multiple appdomains is OK, and has the advantage of getting rid of processes creation overhead (creating a new AppDomains is lighter than creating processes) 如果您仅使用托管代码(这似乎不是您的情况),则具有多个应用程序域的单个进程就可以了,并且它具有消除进程创建开销的优点(创建新的AppDomain比创建进程更轻松) )

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

相关问题 如何在C#中获取单个进程的多个实例详细信息? - How to get multiple instance details of single process in c#? 在C#中创建一个进程以接收多个Chrome本机消息 - Creating a single process in C# to receive multiple Chrome Native Messages 如何在C#中为多个值运行单个进程? - How to run single process for multiple values in c#? 使用 C# windows 应用程序在单个设置中进行多个过程 - multiple process in single set up using C# windows applicarion 单个进程winform应用程序上的多个应用程序域 - Multiple app domains on a single process winform application 我是否需要处理c#应用程序层中的事务以及单次插入以及多次插入的数据库存储过程 - Do I need to handle transaction in c# app layer as well database store process for single insert as well multiple insert C# 运行进程,参数中有多个空格 - C# run process with multiple spaces in arguments C# 多次启动进程 - C# start process multiple times 如何在C#的单个进程中使用线程启动exe appln的多个实例? - How to launch multiple instances of an exe appln using threads in a single process in c#? Process.Start vs Process`p = C#中的新进程()` - Process.Start vs Process `p = new Process()` in C#?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM