简体   繁体   English

是什么导致 IIS 中的应用程序池循环使用?

[英]What causes an application pool in IIS to recycle?

I have been searching for info on this to no avail.我一直在搜索这方面的信息,但无济于事。 The context of why i need this is another question I asked here .我为什么需要这个的背景是我在这里问的另一个问题 More specifically, does creating/updating/deleting files in App_Data cause a pool recycle?更具体地说,在 App_Data 中创建/更新/删除文件会导致池回收吗?

If someone could provide a detailed list of what causes a recycle, that would be great.如果有人可以提供导致回收的原因的详细列表,那就太好了。

UPDATE : As two users already noticed I would also be happy to an answer specifying reasons for recycling the AppDomain only and not the whole pool.更新:正如两个用户已经注意到的那样,我也很乐意回答指定仅回收 AppDomain 而不是整个池的原因。

The article you liked in the other post actually did a really good job of this.您在另一篇文章中喜欢的文章实际上在这方面做得非常好。

Immediate Recycle立即回收

  • Web.config changes Web.config 更改
  • Machine.config changes Machine.config 更改
  • Global.asax changes Global.asax 更改
  • Bin directory changes bin目录变化
  • App_Code changes App_Code 更改

Delayed Recycle延迟回收

Can occur with multiple changes in other locations, typically, I've only noticed this with changes to .aspx or .cs/.vb files though.可能会在其他位置发生多次更改,但通常我只注意到对 .aspx 或 .cs/.vb 文件的更改。 Adding temporary text, csv or other files has not resulted in issues for me.添加临时文本、csv 或其他文件并没有给我带来问题。

NOTE: These are all app-domain recycles, and not actual recycles of the pool.注意:这些都是应用程序域回收,而不是池的实际回收。 Typically the application POOL will only recycle based on settings in IIS (Number of requests, memory limit, idle time, or scheduled restart).通常,应用程序池将仅根据 IIS 中的设置(请求数、内存限制、空闲时间或计划重启)进行回收。

Two different effects:两种不同的效果:

  • The AppPool process is the host for potentially multiple AppDomains. AppPool 进程是潜在的多个 AppDomain 的宿主。 Typically this can be recycled by a number of effects.通常,这可以通过许多效果来回收。 These could be time (every n hours), lack of requests, memory use, etc.;这些可能是时间(每n小时)、请求不足、内存使用等; all configured in IIS Config Manager.所有在 IIS 配置管理器中配置。

  • The AppDomain, the hosted instance of your application root, can be cycled more frequently without affecting other AppDomains in the AppPool. AppDomain(应用程序根的托管实例)可以更频繁地循环,而不会影响 AppPool 中的其他 AppDomain。 Tess's post on AppDomain recycling is pretty insightful. Tess 关于 AppDomain 回收的帖子非常有见地。

You are writing to a folder monitored for recompilation.您正在写入受监视以进行重新编译的文件夹。 This will trigger the AppDomain recreation at some point.这将在某个时候触发 AppDomain 重新创建。

The event log will help you determine what cause initiated the recycle.事件日志将帮助您确定启动回收的原因。

You might want to turn on full AppPool Recycle Event logs:您可能想要打开完整的 AppPool 回收事件日志:

cscript adsutil.vbs Set w3svc/AppPools/DefaultAppPool/LogEventOnRecycle 255 

You also might want to take a look at this Scott Guthrie blog article: http://weblogs.asp.net/scottgu/archive/2005/12/14/433194.aspx that shows how to write code in Global.ASAX to log the actual cause of an Application.End event.您可能还想看看这篇 Scott Guthrie 博客文章: http ://weblogs.asp.net/scottgu/archive/2005/12/14/433194.aspx,它展示了如何在 Global.ASAX 中编写代码以记录Application.End 事件的实际原因。

This has been extremely useful to us in diagnosing several screwy issues - one in partictual was an app that was writing log files to the wwwroot directory - too many file changes resulting in a recycle...这对我们诊断几个棘手的问题非常有用 - 特别是一个将日志文件写入 wwwroot 目录的应用程序 - 太多的文件更改导致回收......

这可以根据偏好每天发生,或者在超过进程的最大虚拟内存时发生。

This is a setting you can manipulate to recycle the app pool based on the number of minutes it has been running, or the number of requests it has processed.这是一个设置,您可以根据应用程序池运行的分钟数或已处理的请求数对其进行操作以回收应用程序池。

It will also recycle on web.config changes and other things that have been posted here.它还将回收 web.config 更改和已在此处发布的其他内容。

An IIS reset will also do the trick, as will stopping/starting services. IIS 重置也可以解决问题,停止/启动服务也是如此。

w3wp.exe was erroring out. w3wp.exe出错了。 This was causing Application_Start to be called in Global.asax .这导致Application_StartGlobal.asax中被调用。

To find this out, I opened Event Viewer .为了找出答案,我打开了Event Viewer

Under Windows Logs I went to Application .Windows Logs下,我去了Application

I saw an Application Error :我看到一个应用程序错误

Faulting application name: w3wp.exe, version: 10.0.16299.15, time stamp: 0x0aeb5595
Faulting module name: KERNELBASE.dll, version: 10.0.16299.334, time stamp: 0x6369e29f
Exception code: 0xe0434352
Fault offset: 0x0000000000014008
Faulting process id: 0x2900
Faulting application start time: 0x01d43b16f726cbb9
Faulting application path: c:\windows\system32\inetsrv\w3wp.exe
Faulting module path: C:\WINDOWS\System32\KERNELBASE.dll
Report Id: 998cf55d-2cd9-4b8d-9884-2110e3fd1411
Faulting package full name: 
Faulting package-relative application ID: 

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

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