Windows Server Cookbook for Windows Server 2003 and Windows 2000
Recipe 12.23. Configuring Application Pool Recycling
Problem
You want to configure an application pool to recycle (restart its associated worker processes) under certain conditions. Solution
Using a graphical user interface
To configure an application pool to recycle automatically, do the following:
To recycle an application pool manually, do the following:
Using a command-line interface
You can't configure application pool recycling from the command line, but once recycling has been configured, you can make IIS log recycling events in the System event log using the following command: > cscript %systemroot%\inetpub\adminscripts\adsutil.vbs set w3svc/AppPools/ <AppPoolName>/<EventName> true
Replace <AppPoolName> with the name of your application pool and <EventName> with one of the recycling events listed in Table 12-10.
Using VBScript
' This code enables app pool recycling ' ------ SCRIPT CONFIGURATION ------ strComputer = "<ServerName>" strAppPoolName = "<AppPoolName>" ' ------ END CONFIGURATION --------- set objAppPool = GetObject("IIS://" & strComputer & "/w3svc/AppPools/" _ & strAppPoolName) objAppPool.AppPoolRecycleRequests = True objAppPool.PeriodicRestartRequests = 2000 objAppPool.SetInfo( ) WScript.Echo "App Pool recycling set successfully: " & objAppPool.Name Discussion
Recycling an application pool restarts any worker processes assigned to the pool. Application pools may be configured to recycle based on different conditions:
Application pools can also be configured to recycle if they consume too much memory, which is typically used for buggy applications that leak memory. Using a command-line interface
Table 12-10 lists the different System events that can be logged for application pool recycling. See Also
MS KB 332088 (How to modify Application Pool Recycling events in IIS 6.0) |