Web サイトに対する既定の制限 <limits>

概要

<siteDefaults> 要素の <limits> 要素には、Web サーバーに対するクライアント要求の帯域幅の量、接続数、または接続タイムアウトを制限する既定の設定を構成します。

Note

特定のサイトに対して <siteDefaults> セクションと <site> セクションの両方に <limits> 要素が構成されている場合は、<site> セクションの構成がそのサイトに対して使用されます。

互換性

バージョン メモ
IIS 8.5 <limits> 要素は IIS 8.5 では変更されませんでした。
IIS 8.0 <limits> 要素は、IIS 8.0 では変更されませんでした。
IIS 7.5 <limits> 要素は IIS 7.5 では変更されませんでした。
IIS 7.0 <siteDefaults> 要素の <limits> 要素が IIS 7.0 で導入されました。
IIS 6.0 <limits> 要素は、次の IIS 6.0 メタベース設定を置き換えます。
  • ConnectionTimeout
  • MaxBandwidth
  • MaxConnections

段取り

<siteDefaults> 要素の <limits> 要素は、IIS 7 以降の既定のインストールに含まれています。

操作方法

サーバーに対して既定の接続制限オプションを構成する方法

  1. インターネット インフォメーション サービス (IIS) マネージャーを開きます。

    • Windows Server 2012 または Windows Server 2012 R2 を使用している場合:

      • タスク バーで、[サーバー マネージャー] をクリックし、[ツール][インターネット インフォメーション サービス (IIS) マネージャー] の順にクリックします。
    • Windows 8 または Windows 8.1 を使用している場合:

      • Windows キーを押しながら文字 X を押し、[コントロール パネル] をクリックします。
      • [管理ツール] をクリックし、[インターネット インフォメーション サービス (IIS) マネージャー] をダブルクリックします。
    • Windows Server 2008 または Windows Server 2008 R2 を使用している場合:

      • タスク バーで、[スタート] ボタンをクリックし、[管理ツール][インターネット インフォメーション サービス (IIS) マネージャー] の順にクリックします。
    • Windows Vista または Windows 7 を使用している場合:

      • タスク バーで、[スタート][コントロール パネル] の順にクリックします。
      • [管理ツール] をダブルクリックし、次に [インターネット インフォメーション サービス (IIS) マネージャー] をダブルクリックします。
  2. [接続] ペインで [サイト] ノードをクリックします。

  3. [サイト] ペインで、[操作] ペインの [Web サイトの既定値の設定] をクリックします。
    [既定の Web サイト] が一覧表示されている [サイト] ウィンドウのスクリーンショット。

  4. [Web サイトの既定値] ダイアログ ボックスで、[制限] を展開し、制限オプションを指定して [OK] をクリックします。
    [全般]、[動作]、[接続の制限]、[失敗した要求トレース] オプションを含む [Web サイトの既定値] ダイアログのスクリーンショット。

構成

属性

属性 説明
connectionTimeout 省略可能な timeSpan 属性。

非アクティブであるとみなされた接続を切断する前に IIS が待機する時間 (秒) を指定します。 接続は、次の理由で非アクティブであるとみなされる可能性があります。
  • HTTP.sys Timer_ConnectionIdle タイマーの有効期限が切れた。 接続は有効期限が切れ、アイドル状態のままになります。
  • HTTP.sys Timer_EntityBody タイマーの有効期限が切れた。 接続は、要求エンティティ本文が到着する前に、有効期限が切れました。 要求にエンティティ本文があることが明らかなときは、HTTP API が Timer_EntityBody タイマーをオンにします。 当初は、このタイマーの制限は connectionTimeout 値に設定されます。 この要求で別のデータ提示が受信されるたびに、HTTP API がタイマーをリセットして、connectionTimeout 属性で指定されているより長い分数を接続に許可します。
  • HTTP.sys Timer_AppPool タイマーの有効期限が切れた。 接続は、サーバー アプリケーションがデキューして処理するのを、要求がアプリケーション プール キュー内で待機する時間が長すぎたために、有効期限が切れました。 このタイムアウト期間は connectionTimeout です。
既定値は 00:02:00 (2 分) です。
maxBandwidth 省略可能な uint 属性。

サイトに使用される最大ネットワーク帯域幅 (バイト/秒) を指定します。 この設定は、IIS アクティビティによってネットワークが過負荷になるのを防止するために使用します。

既定値は 4294967295 です。
maxConnections 省略可能な uint 属性。

サイトの最大接続数を指定します。 この設定は、同時クライアント接続の数を制限するために使用します。

既定値は 4294967295 です。
maxUrlSegments 省略可能な uint 属性。

URL に許可されるセグメントの最大数を指定します。

既定値は 32 です。

子要素

なし。

構成サンプル

次の構成サンプルでは、IIS 7 以降に対して既定の limits オプションを指定します。

<system.applicationHost>
   <sites>
      <siteDefaults>
         <limits connectionTimeout="00:02:00" />
      </siteDefaults>
   </sites>
</system.applicationHost>

サンプル コード

次のコード サンプルでは、IIS 7 以降の既定の limits オプションを 3 分の connectionTimeout で構成します。

AppCmd.exe

appcmd.exe set config -section:system.applicationHost/sites /siteDefaults.limits.connectionTimeout:"00:03:00" /commit:apphost

Note

AppCmd.exe を使用してこれらの設定を構成するときは、commit パラメーターを必ず apphost に設定する必要があります。 これで、ApplicationHost.config ファイルの適切な場所セクションに構成設定がコミットされます。

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:03:00");

         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:03:00")

      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:03:00";

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:03:00"

adminManager.CommitChanges()