IIS 应用程序池、工作进程、应用程序域 [英] IIS app pools, worker processes, app domains

查看:45
本文介绍了IIS 应用程序池、工作进程、应用程序域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

谁能解释 IIS 中应用程序池、工作进程和应用程序域之间的差异?另外,它们是如何协同工作的?我已经阅读了几篇文章,但仍然有点令人困惑.

  1. 在 IIS 中创建的每个网站都会成为一个应用程序吗?
  2. 每个应用程序是否与一个工作进程相关联?
  3. 应用域在哪里出现?

解决方案

我试着用其他词来表达.

在一个服务器中,您可以有许多一起运行的 asp.net 站点.每个站点都是一个应用域.

您必须为他们每个人分配一个应用程序池.许多应用程序域(站点)可以具有相同的应用程序池,并且由于它们具有相同的应用程序池,因此它们在相同的进程和相同的帐户下运行 - 并且它们具有相同的池设置.如果此池重新启动,则该池下的所有站点都会重新启动.

现在每个池可以有一个或多个工作进程.每个工作进程都是运行您站点的不同程序,有它们单独的静态变量,它们不同的启动停止调用等.不同的工作进程不能一起通信,交换数据的唯一方法是来自公共文件或公共数据库.如果您有多个工作进程并且其中一个进行长时间的计算,那么另一个可以处理互联网呼叫和显示内容.

当您将多个工作进程分配给一个池时,您就会创建所谓的网络花园,如果一台计算机是一台处理机器,那么您的站点就像是在多台计算机上运行.>

每个工作进程可以有多个线程.

更多工作进程如何影响您:
当您拥有一个工作进程时,一切都变得更加简单,在您的应用程序中,所有静态变量都是相同的,您可以使用 lock 以同步它们.
当您分配多个工作进程时,您仍然继续对静态变量使用 lock,静态变量在您站点的多次运行中没有区别,如果您有一些公共资源(例如在磁盘上创建缩略图),那么您需要将您的工作进程与 Mutex.

还有一个注意事项.听起来,当您制作更多工作进程时,异步页面加载可能会更顺畅.asp.net 的会话处理程序存在一个小问题,即锁定页面加载的整个过程 - 这是好的还是不好的取决于您是否知道并处理它 - 或更改它.

所以让我们只讨论一个站点有许多工作进程.在这里,您面临需要将公共资源更改与 Mutex 同步的问题.但是使用会话的页面/处理程序不是异步的,因为会话锁定了它们.这是一个很好的开始,因为您可以避免自己进行许多点的同步.

关于这个话题的一些问题:
网络应用在处理另一个网络应用时被阻止关于共享同一会话
jQuery Ajax 对 Web 服务的调用似乎是同步的
ASP.NET 服务器不异步处理页面
完全替换 ASP.Net 的会话

现在这个会话锁不会影响不同的站点.

在不同的站点中,工作越多的流程可以帮助一个站点通过长时间运行的流程阻止另一个站点.
同样在不同的站点之间,更多的池也可以提供帮助,因为每个池至少有一个工作进程,但是使用进程浏览器自己记住和查看,每个工作进程占用更多的计算机内存,以及一台具有 16G 内存的大服务器并且一台 SQL Server 不能有太多不同的工作进程 - 例如,在具有 100 个共享站点的服务器上,您不能有 100 个不同的池.

Can anyone explain the differences, in IIS, between application pools, worker processes and app domains? Also, how do they work together? I've read a couple of articles but it's still a little confusing.

  1. Does each website created in IIS becomes an application?
  2. Is each application associated with one worker process?
  3. Where do app domains come into the picture?

解决方案

I try to say them with other words.

In a server you can have many asp.net sites that runs together. Each one site is an app domain.

You must assign to each of them one application pool. Many application domains (sites) can have the same application pool, and because they have the same application pool they run under the same processes, and under the same account - and they have the same settings of the pool. If this pool restarts, then all sites under that pools restarts.

Now each pool can have one or more worker process. Each worker process is a different program that's run your site, have their alone static variables, they different start stop calls etc. Different worker process are not communicate together, and the only way to exchange data is from common files or a common database. If you have more than one worker process and one of them make long time calculations, then the other can take care to handle the internet calls and show content.

When you assign many worker process to a single pool then you make the called web garden and your site is like to be run from more than one computer if a computer is one processing machine.

Each worker process can have many threads.

How the more worker process affect you:
When you have one worker process everything is more simple, among your application all static variables are the same, and you use the lock to synchronize them.
When you assign more than one worker process then you still continue to use the lock for static variables, static variables are not different among the many runs of your site, and if you have some common resource (e.g. the creation of a thumbnail on the disk) then you need to synchronize your worker process with Mutex.

One more note. Its sounds that when you make more worker process then you may have more smooth asynchronous page loads. There is a small issue with the session handler of asp.net that is lock the entire process for a page load - that is good and not good depend if you know it and handle it - or change it.

So let talk about one site only with many worker process. Here you face the issue that you need to synchronize your common resource change with Mutex. But the pages/handlers that use session they are not asynchronous because the session locks them. This is good for start because you avoid to make this synchronization of many points your self.

Some questions on this topic:
Web app blocked while processing another web app on sharing same session
jQuery Ajax calls to web service seem to be synchronous
ASP.NET Server does not process pages asynchronously
Replacing ASP.Net's session entirely

Now this session lock is not affect different sites.

Among different sites the more worked process can help to not the one site block the other with long running process.
Also among different sites the more pools also can help, because each pool have at least one worked process, but remember and see by your self using the process explorer, each working process takes more memory of your computer, and one big server with 16G memory and one SQL server can not have too many different worked process - for example on a server with 100 shared sites, you can not have 100 different pools.

这篇关于IIS 应用程序池、工作进程、应用程序域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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