How to: Change the Settings for the Request Throttling System

SharePoint 2010

Last modified: March 03, 2011

Applies to: SharePoint Foundation 2010

This topic describes how to programmatically change the settings of the performance monitoring and HTTP request throttling system in Microsoft SharePoint Foundation.

Each SharePoint Foundation web application has its own performance monitoring and request throttling settings. The settings are persisted in the configuration database as an SPHttpThrottleSettings object that is the value of the HttpThrottleSettings property of the web application.

You cannot change the following aspects of the system:

  • Health scores are always integers from 0 to 10, with the lowest score being the healthiest and the highest being the least healthy.

  • The health score of a given monitor is based on a time-weighted average of samples of the counter that is being monitored, and you cannot change the weighting algorithm. (However, there is a way to turn off the use of multiple samples. See the next bulleted list.)

  • A worker process is given an overall health score that is equal to the least healthy score of any of the web application’s registered monitors.

  • A worker process goes into throttling mode only when it has a health score of 10; that is, at least one of the performance monitors has a health score of 10.

  • A worker process goes into second stage throttling only when it has a health score of 10 for at least 60 seconds. This means that, for at least 60 seconds continuously, there has been some monitor or other with a score of 10. However, it is not necessary that a given monitor be continuously at state 10. If monitor A has a score of 10 for a 45-second period, and monitor B has a score of 10 for an overlapping period of 45 seconds, there may be a 60-second span in which there is always at least one monitor that has score 10. In that scenario, the worker process enters second stage throttling.

You can programmatically change the following aspects of the system:

Programmatically enabling or disabling request throttling poses no special challenges. Neither does changing the number of samples that are used to calculate a weighted average or changing the frequency with which counters are sampled. The following code shows the program.cs file of a console application project. The Microsoft Visual Studio project requires a reference to Microsoft.SharePoint.dll, which is located in %ProgramFiles%\Common Files\Microsoft Shared\web server extensions\14\ISAPI. The following code changes the frequency with which samples are taken to 10 seconds from the default of 5 seconds, enables throttle monitoring for the parent web application, and changes the number of samples to 5 from the default of 12. Notice that Update() is called to save the changes to the configuration database.

using Microsoft.SharePoint;
using Microsoft.SharePoint.Administration;
using Microsoft.SharePoint.Utilities;

namespace Contoso.SharePoint.Utilities
    class ThrottleSettingsChanger
        static void Main(string[] args)
            Uri webApplicationUri = new Uri("Http://localhost/");
            SPWebApplication webApplication = SPWebApplication.Lookup(webApplicationUri);

            SPHttpThrottleSettings throttleSettings = SPHttpThrottleSettings.GetHttpThrottleSettings(webApplication);

            throttleSettings.RefreshInterval = 10000;
            throttleSettings.PerformThrottle = true;
            throttleSettings.NumberOfSamples = 5;