IIS应用程序池 - 停止/启动与回收

时间:2022-10-02 22:53:17

I've noticed that on one of my production web apps, when I manually recycle an app pool, the recycled worker process can take upwards of 60+ seconds to actually be completely destroyed, based on watching it in Task Manager. However, if I stop the app pool completely, the worker process goes away nearly instantaneously - within 1-2 seconds.

我注意到,在我的一个生产网络应用程序中,当我手动回收应用程序池时,基于在任务管理器中观察,回收的工作进程可能需要超过60秒以实际完全销毁。但是,如果我完全停止应用程序池,则工作进程几乎立即消失 - 在1-2秒内。

So, my question is two-fold:

所以,我的问题是双重的:

a) Why does it take so long to destroy the process (and more meaningfully, release the resources used/locked by it) when the app pool is recycled instead of stopped; and

a)当应用程序池被回收而不是停止时,为什么要花费这么长时间来销毁进程(更有意义的是,释放由它使用/锁定的资源);和

b) Assuming that I've stopped traffic from being directed to the server, is there any reason NOT to stop/start instead of recycle?

b)假设我已停止将流量导向服务器,是否有任何理由不停止/启动而不是回收?


Edit:
To clarify, before I either recycle or stop the app pool, I stop traffic from being sent to the server in question (the server is in a load balanced cluster, and I remove the server from the load balancer). So, in theory, there should be no requests coming to the web site at the time I am doing anything to the app pool.

编辑:为了澄清,在我回收或停止应用程序池之前,我阻止流量被发送到有问题的服务器(服务器在负载平衡群集中,我从负载均衡器中删除服务器)。因此,从理论上讲,当我对应用程序池执行任何操作时,不应该向网站发出请求。


Edit Part Deux:
After reading Igal's link, it seems pretty obvious to me what is happening. When I recycle the app pool, the new process is started, but since there is no traffic at all, it isn't registering the new process as functioning, so it doesn't shut down the old one until the timeout (which is 90 seconds).

编辑Part Deux:在阅读Igal的链接后,对我来说似乎很明显发生了什么。当我回收应用程序池时,新进程已启动,但由于根本没有流量,因此它没有将新进程注册为正常运行,因此在超时之前它不会关闭旧进程(即90秒)。

With that knowledge, it's clear to me that the "Recycle" functionality is specifically intended to be used midstream on a live server, and since I am manually draining traffic beforehand, I should use stop/start instead.

有了这些知识,我很清楚“回收”功能专门用于在实时服务器的中游使用,而且由于我事先手动排出流量,所以我应该使用停止/启动。

3 个解决方案

#1


a) Because of Overlapped Recycling. There is a time period that the "old" process waits for the new one to start.

a)由于重叠回收。有一段时间“旧”进程等待新进程开始。

b) No. As far as I know.

b)不,据我所知。

#2


A recycle if I recall correctly allows all existing requests to finish then it will recycle the application pool. A stop simply ends it at the exact instant that you stop it.

如果我没记错,回收可以让所有现有的请求完成,然后它将回收应用程序池。停止只是在您停止它的确切时刻结束它。

#3


According to this link,

根据这个链接,

Stopping – by stopping an application pool, you are instructing all IIS worker processes serving this application pool to shut down, and prevent any additional worker processes from being started until the application pool is started again. This initiates a graceful shutdown of the worker processes, with each worker process attempting to drain all of it’s requests and then exit.

停止 - 通过停止应用程序池,您将指示为此应用程序池提供服务的所有IIS工作进程关闭,并阻止在应用程序池再次启动之前启动任何其他工作进程。这会启动工作进程的正常关闭,每个工作进程都会尝试耗尽其所有请求,然后退出。

If a worker process does not exit within the amount of time specified by the shutdownTimeLimit configuration property in the processModel element of each application pool’s definition (default: 90 sec), WAS will forcefully terminate it (this doesnt happen if a native debugger is attached).

如果工作进程没有在每个应用程序池定义的processModel元素中的shutdownTimeLimit配置属性指定的时间内退出(默认值:90秒),WAS将强制终止它(如果连接了本机调试器,则不会发生这种情况) 。

Therefore, stopping an application pool is a disruptive action that causes unload of ASP.NET application domains, FastCGI child processes, and loss of any in-process application state.

因此,停止应用程序池是一种破坏性操作,会导致卸载ASP.NET应用程序域,FastCGI子进程以及丢失任何进程内应用程序状态。

Recycling – recycling an application pool causes all currently running IIS worker processes in that application pool to be gracefully shutdown, but unlike stopping the pool, new IIS worker processes can be started on demand to handle subsequent requests.

回收 - 回收应用程序池会导致该应用程序池中当前正在运行的所有IIS工作进程正常关闭,但与停止池不同,可以根据需要启动新的IIS工作进程以处理后续请求。

Recycling an application pool is a good way to cause the reset of application state and any configuration cached by the IIS worker processes that does not get automatically refreshed (mostly global registry keys), without disrupting the operation of the server. This makes recycling the application pool a great alternative to an IISRESET in most cases.

回收应用程序池是一种很好的方法,可以在不中断服务器操作的情况下,重置应用程序状态以及IIS工作进程缓存的任何未自动刷新的配置(主要是全局注册表项)。这使得在大多数情况下回收应用程序池是IISRESET的一个很好的替代方案。

#1


a) Because of Overlapped Recycling. There is a time period that the "old" process waits for the new one to start.

a)由于重叠回收。有一段时间“旧”进程等待新进程开始。

b) No. As far as I know.

b)不,据我所知。

#2


A recycle if I recall correctly allows all existing requests to finish then it will recycle the application pool. A stop simply ends it at the exact instant that you stop it.

如果我没记错,回收可以让所有现有的请求完成,然后它将回收应用程序池。停止只是在您停止它的确切时刻结束它。

#3


According to this link,

根据这个链接,

Stopping – by stopping an application pool, you are instructing all IIS worker processes serving this application pool to shut down, and prevent any additional worker processes from being started until the application pool is started again. This initiates a graceful shutdown of the worker processes, with each worker process attempting to drain all of it’s requests and then exit.

停止 - 通过停止应用程序池,您将指示为此应用程序池提供服务的所有IIS工作进程关闭,并阻止在应用程序池再次启动之前启动任何其他工作进程。这会启动工作进程的正常关闭,每个工作进程都会尝试耗尽其所有请求,然后退出。

If a worker process does not exit within the amount of time specified by the shutdownTimeLimit configuration property in the processModel element of each application pool’s definition (default: 90 sec), WAS will forcefully terminate it (this doesnt happen if a native debugger is attached).

如果工作进程没有在每个应用程序池定义的processModel元素中的shutdownTimeLimit配置属性指定的时间内退出(默认值:90秒),WAS将强制终止它(如果连接了本机调试器,则不会发生这种情况) 。

Therefore, stopping an application pool is a disruptive action that causes unload of ASP.NET application domains, FastCGI child processes, and loss of any in-process application state.

因此,停止应用程序池是一种破坏性操作,会导致卸载ASP.NET应用程序域,FastCGI子进程以及丢失任何进程内应用程序状态。

Recycling – recycling an application pool causes all currently running IIS worker processes in that application pool to be gracefully shutdown, but unlike stopping the pool, new IIS worker processes can be started on demand to handle subsequent requests.

回收 - 回收应用程序池会导致该应用程序池中当前正在运行的所有IIS工作进程正常关闭,但与停止池不同,可以根据需要启动新的IIS工作进程以处理后续请求。

Recycling an application pool is a good way to cause the reset of application state and any configuration cached by the IIS worker processes that does not get automatically refreshed (mostly global registry keys), without disrupting the operation of the server. This makes recycling the application pool a great alternative to an IISRESET in most cases.

回收应用程序池是一种很好的方法,可以在不中断服务器操作的情况下,重置应用程序状态以及IIS工作进程缓存的任何未自动刷新的配置(主要是全局注册表项)。这使得在大多数情况下回收应用程序池是IISRESET的一个很好的替代方案。