Create a new request throttling strategy

Last updated Wednesday, June 13, 2018 in Sitecore Experience Platform for Developer
Keywords: Development

This topic is valid for Sitecore 9, Update 2, and later.

You can create a new request throttling strategy. You must:

Create a strategy item template

To add a strategy item template:

  1. Create a new template under /sitecore/templates/System/Services/Throttle, using the /System/Templates/Template template. Add fields and set the base template to /sitecore/templates/System/Services/Throttle/Strategy template.
  2. To configure the insert rules, add the template you created to the list in the Masters field in the /sitecore/templates/System/Services/Throttle/Strategy Folder/__Standard Values item.
  3. Add standard values for the template you created and set the default values for the fields:

    Picture 17

Implement a strategy class

To create a strategy class:

  1. In Visual Studio, create a project, and create a strategy class that inherits from the DataThrottleStrategy base class.
  2. You must implement these three methods:
    • InitCore – Put all initialization steps here (for example, binding the strategy properties to strategy item fields.
    • VerifyCore – Put the logic that specifies whether a request is allowed or not here. You can save the internal state in the CustomData field of the ThrottleStrategyData class. An instance of this class is passed as an argument to the method.
    • CommitCore – Use this method if all the strategies allowed the request and the strategy can change its internal state if it needs to do it.
  3. Put the binary assembly file in the bin folder of your Sitecore instance.

The following is an example of a strategy class implementation:

using System;
using System.Globalization;
using Sitecore.Diagnostics;
using Sitecore.Services.Infrastructure.Throttle;
using Sitecore.Services.Infrastructure.Throttle.Strategies;
namespace CustomService.Throttle.Strategies
    public class MyCustomStrategy : DataThrottleStrategy
        private int _customField;
        private int _result;
        private MyCustomData _myCustomData;
        public MyCustomStrategy(ThrottleStrategyDataStorage storage) : base(storage)
        protected override void InitCore(ThrottleInitializationContext throttleInitializationContext)
            // get parameters from item
            Assert.ArgumentNotNull(throttleInitializationContext.StrategyItem, nameof(throttleInitializationContext.StrategyItem));
            _customField = int.Parse(throttleInitializationContext.StrategyItem["{D55875C2-D5CA-48D9-8FBD-8092887F980F}"], CultureInfo.InvariantCulture);
            Assert.ArgumentCondition(_customField > 0, nameof(_customField), "Custom parameter is lower or equal 0");
        protected override ThrottleStrategyResult VerifyCore(ThrottleStrategyData throttleStrategyData)
            _myCustomData = throttleStrategyData.CustomData as MyCustomData;
            if (_myCustomData != null)
                _result = _myCustomData.Rnd.Next(0, _customField);
                // if random number is in second half of 0.._customField span then the request is not passed
                if (_result > _customField / 2)
                    return new ThrottleStrategyResult
                        Passed = false,
                        RetryAfter = 5
            return ThrottleStrategyResult.PassedResult;
        protected override void CommitCore()
            _myCustomData.Result = _result;
    internal class MyCustomData
        internal readonly Random Rnd = new Random();
        internal int Result;

Apply the strategy

To apply the strategy:

  • Create a strategy item from the strategy template you created:

Picture 18

Now you can apply the strategy with the HYPERLINK \l "_Applying_strategies" methods described.

Send feedback about the documentation to