Why IIS6 Application Pool Recycle Events are not logged


Question:


Hi,


I would like IIS to log application pool recycle events.  I followed this article


http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/87892589-4eda-4003-b4ac-3879eac4bf48.mspx


restarted IIS and even rebooted the machine then recycled the app pool that I want to log events on, but the recycle events aren’t being written to the system log or any other log that I can see.  Anyone have any ideas what I might be doing wrong?


Cheers,


Answer:


The reason you are not seeing recycle events written to the event log is because no worker processes actually recycled when you demand-recycled the application pool. In other words, the IIS Manager UI always gives you the option to trigger “Recycle” of the application pool, but if no worker processes are currently running and servicing the application pool, no worker processes actually recycle and hence no event log gets written.


For efficiency and reliability reasons, IIS6 demand-starts worker processes for application pools. What this means is that you can define 100 applications, each with its own application pool, but until a request is made to that application, no worker process (and hence no system resources) are consumed. Default configuration also has “idle timeout” where the worker process terminates itself and release system resources when it has not handled any requests for the specified amount of time. Both demand-start and idle-timeout allow IIS6 to naturally optimize system resources towards active applications.


What this means is that when you restarted IIS or rebooted the system, no one has made any requests to your server to demand-start any worker processes… so none are running and you obviously cannot demand recycle non-existent worker processes…


Thus, to see your configuration work, simply first make a request to a URL serviced by the application pool you plan to recycle, and then do the demand-recycle of the application pool in the IIS Manager UI. You should now see an event log entry in the System event log.


And, this feature works dynamically as soon as you set the metabase property – no IIS restart or server reboot required.


//David

Comments (8)

  1. ppateel says:

    We have a big difference of opinion on the App pool recycle issue. The question is if I do an IISRESET does that recycle all App polls or is there  a situation where an IISRESET will not recycle app pools

  2. David.Wang says:

    ppateel – IISRESET forcibly restarts all of IIS, killing its processes as necessary, so it does more than just recycle all Application Pools.

    //David

  3. Prahalad says:

    David,

     Thanks for the reply. Yes, I know that. But me and my colleague were having an academic discussion whether IISRESET will recycle all application pools or in some cases leaves application pools still alive requiring an explicit App pool recycle action after an IISRESET. My take was that since the w3wp.exe is dependent on IIS IISRESET will in every single case will Kill all w3wp.exe worker processes and an App pool recycle is not necessary after an IISRESET.  I did not know whether that was really the case and I searched extensively and I was unable to dig up any literature to back my theory so I am questioning whether I was correct in the first place. Any light or pointer to where I should look will really me in understanding this issue.

    Thank you so much for taking time to reply to my question,

    Prahalad

  4. David.Wang says:

    Prahalad – actually, if Orphaning is enabled (not enabled by default), orphaned w3wp.exe (which never handle any more requests) will remain after IISRESET. However, Application Pool Recycle won’t do anything, either. Orphaned w3wp.exe are just that — orphaned — and no longer under control/watch of IIS and hence can hang around.

    //David

  5. Prahalad says:

    David. Thanks for your clarification.

  6. Ram Dash says:

    I don’t know whether orphaning was enabled, but I’ve seen that an IISRESET doesn’t necessarily stop all w3wp.exe processes. Moreover, an IISRESET may not cleanly stop IIS. In that case, you need to kill the inetinfo.exe process and then try to do IISRESET.

  7. Edmund says:

    Hi,

    I am running Windows Server 2003 with default settings and have some application pools in isolation mode.

    The server works well except the fact I have some unexplained worker process recycles. (BTW, I have the app pools set to recycle at a specific time during the night).

    So I changed the LogEventOnRecycle to 255 but do not see any such event logged. I am manually recycling the pool (it is indeed recycling as I see at the task manager’s processes tab).

    I also tried clearing the Application Event log.

    Any idea why events are not logged?

    Thanks,

    Edmund

  8. Scott Pollard says:

    D'oh! I've been trying to see app pool recycle logging show up to no avail. Your explanation nailed it. Thank you!