Limits for All Sites <limits>

Overview

The <limits> element of the <siteDefaults> element configures the default settings that limit the amount of bandwidth, the number of connections, or the connection time-out for client requests to a site.

Note: If the <limits> element is configured in both the <siteDefaults> section and in the <site> section for a specific site, the configuration in the <site> section is used for that site.

Compatibility

  IIS 7.0 IIS 6.0
Notes The <limits> element of the <siteDefaults> element is new in IIS 7.0. The <limits> element replaces the following IIS 6.0 metabase settings:

ConnectionTimeout
MaxBandwidth
MaxConnections

Setup

The <limits> element of the <siteDefaults> element is included in the default installation of IIS 7.0.

How To

How to configure the default connection limit options for a server

  1. On the taskbar, click Start, point to Administrative Tools, and then click Internet Information Services (IIS) Manager.
  2. In the Connections pane, expand the server name, then click the Sites node.
  3. In the server's Sites pane, click Set Web Site Defaults... in the Actions pane.

  4. In the Web Site Defaults dialog box, expand Connection Limits, specify your default connection limits options for all Web sites, and then click OK.

Configuration

Attributes

Attribute Description
connectionTimeout Optional timeSpan attribute.

Specifies the time (in seconds) that IIS waits before it disconnects a connection that is considered inactive. Connections can be considered inactive for the following reasons:
  • The HTTP.sys Timer_ConnectionIdle timer expired. The connection expired and remains idle.
  • The HTTP.sys Timer_EntityBody timer expired. The connection expired before the request entity body arrived. When it is clear that a request has an entity body, the HTTP API turns on the Timer_EntityBody timer. Initially, the limit of this timer is set to the connectionTimeout value. Each time another data indication is received on this request, the HTTP API resets the timer to give the connection more minutes as specified in the connectionTimeout attribute.
  • The HTTP.sys Timer_AppPool timer expired. The connection expired because a request waited too long in an application pool queue for a server application to dequeue and process it. This time-out duration is connectionTimeout.

The default value is 00:02:00 (two minutes).

maxBandwidth Optional uint attribute.

Specifies the maximum network bandwidth used for a site. Use this setting to help prevent overloading the network with IIS activity.

The default value is 4294967295.
maxConnections Optional uint attribute.

Specifies the maximum number of connections for a site. Use this setting to limit the number of simultaneous client connections.

The default value is 4294967295.

Child Elements

None.

Configuration Sample

The following example shows how to configure default connection limits settings for all sites.

<sites>
   <siteDefaults>
     <limits
         connectionTimeout="150"
         maxBandwidth="967295"
         maxConnections="150"
      />
   </siteDefaults>
</sites>

Sample Code

The following code samples configure the default connection limits for IIS 7.0.

AppCmd.exe

appcmd.exe set config -section:system.applicationHost/sites /siteDefaults.limits.connectionTimeout:"00:02:00" /commit:apphost
appcmd.exe set config -section:system.applicationHost/sites /siteDefaults.limits.maxBandwidth:"967295" /commit:apphost
appcmd.exe set config -section:system.applicationHost/sites /siteDefaults.limits.maxConnections:"150" /commit:apphost

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 sitesSection = config.GetSection("system.applicationHost/sites");
         ConfigurationElement siteDefaultsElement = sitesSection.GetChildElement("siteDefaults");

         ConfigurationElement limitsElement = siteDefaultsElement.GetChildElement("limits");
         limitsElement["connectionTimeout"] = TimeSpan.Parse("00:02:00");
         limitsElement["maxBandwidth"] = 967295;
         limitsElement["maxConnections"] = 150;

         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 sitesSection As ConfigurationSection = config.GetSection("system.applicationHost/sites")
      Dim siteDefaultsElement As ConfigurationElement = sitesSection.GetChildElement("siteDefaults")

      Dim limitsElement As ConfigurationElement = siteDefaultsElement.GetChildElement("limits")
      limitsElement("connectionTimeout") = TimeSpan.Parse("00:02:00")
      limitsElement("maxBandwidth") = 967295
      limitsElement("maxConnections") = 150

      serverManager.CommitChanges()
   End Sub

End Module

JavaScript

var adminManager = new ActiveXObject('Microsoft.ApplicationHost.WritableAdminManager');
adminManager.CommitPath = "MACHINE/WEBROOT/APPHOST";
var sitesSection = adminManager.GetAdminSection("system.applicationHost/sites", "MACHINE/WEBROOT/APPHOST");
var siteDefaultsElement = sitesSection.ChildElements.Item("siteDefaults");

var limitsElement = siteDefaultsElement.ChildElements.Item("limits");
limitsElement.Properties.Item("connectionTimeout").Value = "00:02:00";
limitsElement.Properties.Item("maxBandwidth").Value = 967295;
limitsElement.Properties.Item("maxConnections").Value = 150;

adminManager.CommitChanges();

VBScript

Set adminManager = WScript.CreateObject("Microsoft.ApplicationHost.WritableAdminManager")
adminManager.CommitPath = "MACHINE/WEBROOT/APPHOST"
Set sitesSection = adminManager.GetAdminSection("system.applicationHost/sites", "MACHINE/WEBROOT/APPHOST")
Set siteDefaultsElement = sitesSection.ChildElements.Item("siteDefaults")

Set limitsElement = siteDefaultsElement.ChildElements.Item("limits")
limitsElement.Properties.Item("connectionTimeout").Value = "00:02:00"
limitsElement.Properties.Item("maxBandwidth").Value = 967295
limitsElement.Properties.Item("maxConnections").Value = 150

adminManager.CommitChanges()
Configuration Settings
View by Schema

Depricated Elements

Microsoft Communities