Overview

The <recycling> element contains configuration settings that control the conditions that trigger IIS 7 to restart an application pool. You can also control the types of events IIS writes to the event log when the application pool recycles.

You can specify that IIS recycle an application pool at set intervals (such as every 180 minutes), at a specific time each day, or after the application pool receives a certain number of requests. You can also configure the <recycling> element to restart the application pool when the worker process virtual memory and physical memory usage reaches a specific threshold.

You can use the <recycling> element to specify two classes of events to log to the event log when IIS recycles an application pool. The first class contains recycling events that you can configure, such as those mentioned in the previous paragraph. The second class includes run-time recycling events, such as on-demand recycling events, recycling events triggered by configuration changes in the application or applications running in the application pool, or recycling caused by an unhealthy Internet Server Application Programming Interface (ISAPI) filter or ISAPI extension.

The <recycling> element uses the following attribute and child element to implement these features:

  • logEventOnRecycle attribute
  • periodicRestart element

Compatibility

Version Notes
IIS 8.5 The <recycling> element was not modified in IIS 8.5.
IIS 8.0 The <recycling> element was not modified in IIS 8.0.
IIS 7.5 The <recycling> element was not modified in IIS 7.5.
IIS 7.0 The <recycling> element was introduced in IIS 7.0.
IIS 6.0 The <recycling> element replaces portions of the IIS 6.0 IIsApplicationPools metabase property.

Setup

The <applicationPools> collection is included in the default installation of IIS 7.

How To

HOW TO SET UP PERIODIC RECYCLING FOR AN APPLICATION POOL

  1. Open Internet Information Services (IIS) Manager:

    • If you are using Windows Server 2012 or Windows Server 2012 R2:

      • On the taskbar, click Server Manager, click Tools, and then click Internet Information Services (IIS) Manager.
    • If you are using Windows 8 or Windows 8.1:
      • Hold down the Windows key, press the letter X, and then click Control Panel.
      • Click Administrative Tools, and then double-click Internet Information Services (IIS) Manager.
    • If you are using Windows Server 2008 or Windows Server 2008 R2:
      • On the taskbar, click Start, point to Administrative Tools, and then click Internet Information Services (IIS) Manager.
    • If you are using Windows Vista or Windows 7:
      • On the taskbar, click Start, and then click Control Panel.
      • Double-click Administrative Tools, and then double-click Internet Information Services (IIS) Manager.
  2. In the Connections pane, expand the server name, and then click Application Pools.
  3. In the Application Pools pane, select the application pool you want edit.
  4. In the Actions pane, click Recycling... 
  5. On the Recycling Conditions page of the Edit Application Pool Recycling Settings Wizard, select at least one of the options in the Fixed Intervals section, type values into the appropriate text boxes, and then click Next.
  6. (Optional) On the Recycling Events to Log page of the Edit Application Pool Recycling Settings Wizard, select the configurable recycling events and run-time recycling events that you want IIS to send to the event log when they occur, and then click Finish.

    Note: By default, IIS sends the Regular time intervals, Virtual memory usage, and Private memory usage configurable recycling events to the event log. The other configurable recycling events are available for logging only if you have enabled the logging event on the Recycling Conditions page.

Configuration

The <recycling> element is configurable at the server level in the ApplicationHost.config file.

ATTRIBUTES

Attribute Description
disallowOverlappingRotation Optional Boolean attribute.

Specifies whether the WWW Service should start another worker process to replace the existing worker process while that process is shutting down. The value of this property should be set to true if the worker process loads any application code that does not support multiple worker processes.

The default value is false.

disallowRotationOnConfigChange Optional Boolean attribute.

Specifies whether the WWW Service should rotate worker processes in an application pool when the configuration has changed.

The default value is false.

logEventOnRecycle Optional flags attribute.

Specifies that IIS should log an event when an application pool is recycled. ThelogEventOnRecycle property must have a bit set corresponding to the reason for the recycle if IIS is to log the event.

The logEventOnRecycle attribute can have one or more of the following possible values. If you specify more than one value, separate them with a comma (,). The default values are TimeMemory, and PrivateMemory.

Value Description
ConfigChange Log an event when an application pool recycles because of a configuration change.

The numeric value is 64.

IsapiUnhealthy Log an event when an application pool recycles after an ISAPI extension reports to the worker process that it is in an unhealthy state. 
The numeric value is 16.
Memory Log an event when an application pool recycles after it uses a specified amount of virtual memory.

The numeric value is 8.

OnDemand Log an event when an application pool is recycled immediately to correct a problem.

The numeric value is 32.

PrivateMemory Log an event when an application pool recycles after it uses a specified amount of virtual memory.

The numeric value is 128.

Requests Log an event when an application pool recycles after it reaches a configured number of requests.

The numeric value is 2.

Schedule Log an event when an application pool recycles after it reaches a configured time of day.

The numeric value is 4.

Time Log an event when an application pool recycles after a configured time.

The numeric value is 1.

CHILD ELEMENTS

Element Description
periodicRestart Optional element.

Specifies conditions under which application pools are recycled.

CONFIGURATION SAMPLE

The following configuration sample uses the application pool <add> element to create a new application pool named Contoso. The <recycling> element configures logging for application pool restarts, the <periodicRestart> element configures when the application pool restarts, and the <processModel> element configures the shutdownTimeLimit and startupTimeLimitattributes for shutting down and starting the worker processes in the application pool for 30 seconds each. If these time limits are exceeded, IIS terminates the worker process.

<add name="Contoso">
<recycling logEventOnRecycle="Schedule">
<periodicRestart>
<schedule>
<clear />
<add value="03:00:00" />
</schedule>
</periodicRestart>
</recycling>
<processModel identityType="NetworkService" shutdownTimeLimit="00:00:30" startupTimeLimit="00:00:30" />
</add>

Sample Code

The following code examples add an application pool named Contoso to your IIS 7 server, then set the application pool to daily recycle at 3:00 A.M.

APPCMD.EXE

appcmd.exe set config -section:system.applicationHost/applicationPools /+"[name='Contoso']" /commit:apphost

appcmd.exe set config -section:system.applicationHost/applicationPools /+"[name='Contoso'].recycling.periodicRestart.schedule.[value='03:00:00']" /commit:apphost

You can also use the following syntax:

appcmd.exe add apppool /name:"Contoso"

appcmd.exe set config -section:system.applicationHost/applicationPools /+"[name='Contoso'].recycling.periodicRestart.schedule.[value='03:00:00']" /commit:apphost

Note: You must be sure to set the commit parameter to apphost when you use AppCmd.exe to configure these settings. This commits the configuration settings to the appropriate location section in the ApplicationHost.config file.

C#

using System;
using System.Text;
using Microsoft.Web.Administration; internal static class Sample
{
private static void Main()
{
using (ServerManager serverManager = new ServerManager())
{
Configuration config = serverManager.GetApplicationHostConfiguration();
ConfigurationSection applicationPoolsSection = config.GetSection("system.applicationHost/applicationPools");
ConfigurationElementCollection applicationPoolsCollection = applicationPoolsSection.GetCollection();
ConfigurationElement addElement = applicationPoolsCollection.CreateElement("add");
addElement["name"] = @"Contoso";
ConfigurationElement recyclingElement = addElement.GetChildElement("recycling");
ConfigurationElement periodicRestartElement = recyclingElement.GetChildElement("periodicRestart");
ConfigurationElementCollection scheduleCollection = periodicRestartElement.GetCollection("schedule");
ConfigurationElement addElement1 = scheduleCollection.CreateElement("add");
addElement1["value"] = TimeSpan.Parse("03:00:00");
scheduleCollection.Add(addElement1);
applicationPoolsCollection.Add(addElement);
serverManager.CommitChanges();
}
}
}

VB.NET

Imports System
Imports System.Text
Imports Microsoft.Web.Administration Module Sample
Sub Main()
Dim serverManager As ServerManager = New ServerManager
Dim config As Configuration = serverManager.GetApplicationHostConfiguration
Dim applicationPoolsSection As ConfigurationSection = config.GetSection("system.applicationHost/applicationPools")
Dim applicationPoolsCollection As ConfigurationElementCollection = applicationPoolsSection.GetCollection
Dim addElement As ConfigurationElement = applicationPoolsCollection.CreateElement("add")
addElement("name") = "Contoso"
Dim recyclingElement As ConfigurationElement = addElement.GetChildElement("recycling")
Dim periodicRestartElement As ConfigurationElement = recyclingElement.GetChildElement("periodicRestart")
Dim scheduleCollection As ConfigurationElementCollection = periodicRestartElement.GetCollection("schedule")
Dim addElement1 As ConfigurationElement = scheduleCollection.CreateElement("add")
addElement1("value") = TimeSpan.Parse("03:00:00")
scheduleCollection.Add(addElement1)
applicationPoolsCollection.Add(addElement)
serverManager.CommitChanges()
End Sub
End Module

JAVASCRIPT

var adminManager = new ActiveXObject('Microsoft.ApplicationHost.WritableAdminManager');
adminManager.CommitPath = "MACHINE/WEBROOT/APPHOST";
var applicationPoolsSection = adminManager.GetAdminSection("system.applicationHost/applicationPools", "MACHINE/WEBROOT/APPHOST");
var applicationPoolsCollection = applicationPoolsSection.Collection; var addElement = applicationPoolsCollection.CreateNewElement("add");
addElement.Properties.Item("name").Value = "Contoso";
var recyclingElement = addElement.ChildElements.Item("recycling");
var periodicRestartElement = recyclingElement.ChildElements.Item("periodicRestart");
var scheduleCollection = periodicRestartElement.ChildElements.Item("schedule").Collection;
var addElement1 = scheduleCollection.CreateNewElement("add");
addElement1.Properties.Item("value").Value = "03:00:00";
scheduleCollection.AddElement(addElement1);
applicationPoolsCollection.AddElement(addElement); adminManager.CommitChanges();

VBSCRIPT

Set adminManager = createObject("Microsoft.ApplicationHost.WritableAdminManager")
adminManager.CommitPath = "MACHINE/WEBROOT/APPHOST"
Set applicationPoolsSection = adminManager.GetAdminSection("system.applicationHost/applicationPools", "MACHINE/WEBROOT/APPHOST")
Set applicationPoolsCollection = applicationPoolsSection.Collection Set addElement = applicationPoolsCollection.CreateNewElement("add")
addElement.Properties.Item("name").Value = "Contoso"
Set recyclingElement = addElement.ChildElements.Item("recycling")
Set periodicRestartElement = recyclingElement.ChildElements.Item("periodicRestart")
Set scheduleCollection = periodicRestartElement.ChildElements.Item("schedule").Collection
Set addElement1 = scheduleCollection.CreateNewElement("add")
addElement1.Properties.Item("value").Value = "03:00:00"
scheduleCollection.AddElement(addElement1)
applicationPoolsCollection.AddElement(addElement) adminManager.CommitChanges()

Recycling Settings for an Application Pool <recycling>的更多相关文章

  1. 【Azure 云服务】在Cloud Service的代码中如何修改IIS Application Pool的配置呢? 比如IdleTimeout, startMode, Recycling.PeriodicRestart.Time等

    什么是 PaaS?Platform as a Service 平台即服务 (PaaS) 是云中的完整开发和部署环境,你可以使用其中资源交付内容,从基于云的简单应用到启用云的复杂企业应用程序皆可.你以即 ...

  2. Application Pool Identities

    Whether you are running your site on your own server or in the cloud, security must be at the top of ...

  3. IIS application pool access desktop denied

    https://stackoverflow.com/questions/5437723/iis-apppoolidentity-and-file-system-write-access-permiss ...

  4. 如何在Windows 2003+IIS6的环境下找回应用程序池(application pool)中的服务账号密码

    上一篇文章说了说如何在Win2008+iis7中取出SharePoint管理账号密码的方法. 整个过程简单的讲,就是通过使用要找回密码的账号用来在SharePoint中创建一个临时的Web Appli ...

  5. IIS7 Application Pool Integrate Mode 和 Classic Mode 的区别

    IIS7也用了好久了,关于Application Pool Integrate Mode 和 Classic Mode 究竟是什么也是懵懵懂懂,于是下决心去官网看了技术文档,终于恍然大悟,特来分享一下 ...

  6. How do I create an IIS application and application pool using InnoSetup script

    Create an IIS application. Create a new IIS application pool and set it's .NET version to 4. Set the ...

  7. 排错技能:任务管理器中追踪某w3wp.exe是哪个IIS站点的application pool

    如果Windows的任务管理器中发现某个w3wp.exe占用了100%CPU,那我们就要揪出这是那个网站的application pool在作怪, 首先,每个站点一定要单独使用各自的applicati ...

  8. 批量启动application pool

    在powershell中执行 Get-ChildItem IIS:\AppPools | where {$_.state -eq "Stopped"} | Start-WebApp ...

  9. SharePoint Error occurred in deployment step 'Recycle IIS Application Pool': 0x80070005:拒绝访问

    错误出现的前提:多个用户在一台机器上做开发,使用非系统管理员账号时会出现,因为一般创建网站集时指定管理员为系统管理员: 使用 Visual Studio 2010 部署时报错:Error occurr ...

随机推荐

  1. MFC中使用sqlite3操作数据库

    需要用到的文件有sqlite3.h .sqlite3.dll.sqlite3.lib.网上很多人分享下载地址这里不再赘述. 将这三个文件拷贝到自己新建MFC项目目录下,在解决方案窗口下 添加现有项,选 ...

  2. Python学习杂记_15_正则表达式

    正则表达式 正则表达式就是用来查找字符串的,它能够查找规则比较复杂的字符串.使用正则表达式首先要导入re模块import re s = "besttest is good!besttest ...

  3. 线段树【p1607】[USACO09FEB]庙会班车Fair Shuttle

    Description 逛逛集市,兑兑奖品,看看节目对农夫约翰来说不算什么,可是他的奶牛们非常缺乏锻炼--如果要逛完一整天的集市,他们一定会筋疲力尽的.所以为了让奶牛们也能愉快地逛集市,约翰准备让奶牛 ...

  4. android利用adb修改手机的分辨率和dpi

    在android开发过程中,适配更多的适配是必不可少的一步,而每次测试适配时,要么购买设配,要么模拟器,买设配太花钱,模拟器太占内存,不过幸好还可以通过修改手机的size(分辨率)和density来进 ...

  5. POJ 3420 Quad Tiling (矩阵乘法)

    [题目链接] http://poj.org/problem?id=3420 [题目大意] 给出一个4*n的矩阵,求用1*2的骨牌填满有多少方案数 [题解] 弄出不同情况的继承关系,用矩阵递推即可. [ ...

  6. Flash 3D学习计划

    1.理解并记住3D渲染的一般管线流程(一天). 2.理解世界,取景,投影变换,并理解投影坐标系(一天). 3.学习VB,IB相关,理解三角形顶点顺序:在屏幕上显示2D矩形,并实现缩放,平移,旋转(三天 ...

  7. 用swift开发自己的MacOS锁屏软件(二)

    上一篇中尝试写了hello world,这一篇中,开始尝试锁屏功能 1.尝试查找swift有没有相关的函数,可以控制系统锁屏之类的,结果并没有找到 2.尝试查找cocoa有没有相关的接口,结果仍然没有 ...

  8. alter table锁表,MySQL出现Waiting for table metadata lock的场景浅析及解决方案

    在修改/增加表字段的时候,发现很慢, show processlist; 时, Waiting for table metadata lock 能一直锁很久. 官网的一段话,可以理解下 http:// ...

  9. 分布式数据库以及OS

    http://blog.csdn.net/longronglin/article/category/230501

  10. 蛋疼的VS2010 tab group

    http://superuser.com/questions/232031/why-does-my-visual-studio-2010-default-to-a-horizontal-windows ...