What causes an application pool in IIS to recycle?

2019-01-01 08:38发布

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?

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.

6条回答
与风俱净
2楼-- · 2019-01-01 08:59

The article you liked in the other post actually did a really good job of this.

Immediate Recycle

  • Web.config changes
  • Machine.config changes
  • Global.asax changes
  • Bin directory changes
  • App_Code changes

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. Adding temporary text, csv or other files has not resulted in issues for me.

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).

查看更多
骚的不知所云
3楼-- · 2019-01-01 09:13

This can happen on a daily basis based on preferences, or when the max virtual memory for the process has been exceeded.

查看更多
与风俱净
4楼-- · 2019-01-01 09:14

w3wp.exe was erroring out. This was causing Application_Start to be called in Global.asax.

To find this out, I opened Event Viewer.

Under Windows Logs I went to 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: 
查看更多
流年柔荑漫光年
5楼-- · 2019-01-01 09:16

Two different effects - the AppPool process is the host for potentially multiple appdomains. Typically this can be recycled by a number of effects e.g. time - every 'n' hours, lack of requests, memory use etc. Configured in IIS Config Manager.

AppDomain - the hosted instance of your application root, can be cycled more frequently without affecting other AppDomains in the AppPool. Tess' post on AppDomain recycling is pretty insightful

http://blogs.msdn.com/tess/archive/2006/08/02/asp-net-case-study-lost-session-variables-and-appdomain-recycles.aspx

You are writing to a folder monitored for recompilation - this will trigger the appdomain recreation at some point.

Event log will help you determine cause initiated the recycled.

查看更多
有味是清欢
6楼-- · 2019-01-01 09:18

You might want to turn on full AppPool Recycle Event logs:

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.

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...

查看更多
后来的你喜欢了谁
7楼-- · 2019-01-01 09:20

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.

An IIS reset will also do the trick, as will stopping/starting services.

查看更多
登录 后发表回答