Recipe 12.23. Configuring Application Pool RecyclingProblemYou want to configure an application pool to recycle (restart its associated worker processes) under certain conditions. SolutionUsing a graphical user interfaceTo configure an application pool to recycle automatically, do the following:
To recycle an application pool manually, do the following:
Using a command-line interfaceYou 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 DiscussionRecycling 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 interfaceTable 12-10 lists the different System events that can be logged for application pool recycling. See AlsoMS KB 332088 (How to modify Application Pool Recycling events in IIS 6.0) |