Throttlebird is a simple Http request throttler to help limit the number of client requests within a given period of time.
Перейти к файлу
Joel Hulen a703363c9e Update README.md 2015-12-28 14:32:34 -08:00
AppvNext.Throttlebird * Added new references 2015-12-05 19:26:19 -08:00
.gitattributes Initial commit to add default .gitIgnore and .gitAttribute files. 2015-12-05 16:16:15 -08:00
.gitignore Initial commit to add default .gitIgnore and .gitAttribute files. 2015-12-05 16:16:15 -08:00
AppvNext.Throttlebird.sln Initial commit 2015-12-05 18:16:36 -08:00
GitVersionConfig.yaml * Added new references 2015-12-05 19:26:19 -08:00
LICENSE.txt Initial commit 2015-12-05 18:16:36 -08:00
README.md Update README.md 2015-12-28 14:32:34 -08:00
appveyor.yml Added AppVeyor configuration file 2015-12-05 18:25:06 -08:00
build.bat Initial commit 2015-12-05 18:16:36 -08:00
build.cake Fixed NuGet source directory portion of the cake build file 2015-12-05 18:29:15 -08:00
build.ps1 Modified the build file to download the latest version of NuGet (in this case, 3.0) 2015-12-05 19:32:27 -08:00

README.md

 ______  __ __  ____    ___   ______  ______  _        ___  ____   ____  ____   ___   
|      T|  T  T|    \  /   \ |      T|      T| T      /  _]|    \ l    j|    \ |   \  
|      ||  l  ||  D  )Y     Y|      ||      || |     /  [_ |  o  ) |  T |  D  )|    \ 
l_j  l_j|  _  ||    / |  O  |l_j  l_jl_j  l_j| l___ Y    _]|     T |  | |    / |  D  Y
  |  |  |  |  ||    \ |     |  |  |    |  |  |     T|   [_ |  O  | |  | |    \ |     |
  |  |  |  |  ||  .  Yl     !  |  |    |  |  |     ||     T|     | j  l |  .  Y|     |
  l__j  l__j__jl__j\_j \___/   l__j    l__j  l_____jl_____jl_____j|____jl__j\_jl_____j

Throttlebird

Throttlebird is a simple http request throttler to help limit the number of client requests within a given period of time.

NuGet version Build status

Example

In your WebApiConfig file under the App_Start folder of your ASP.NET MVC project, add the following code block within the Register method:

// Implement our custom throttling handler to limit API method calls.
// Specify the throttle store, max number of allowed requests within specified timespan,
// and message displayed in the error response when exceeded.
config.MessageHandlers.Add(new ThrottlingHandler(
    new InMemoryThrottleStore(),
    id => 3,
    TimeSpan.FromSeconds(5),
    "You have exceeded the maximum number of allowed calls. Please wait until after the cooldown period to try again."
));

This works across all http requests on your site, limiting the number of requests to 3 every 5 seconds. To adjust, simply modify the id parameter to the number of requests, and the timespan to any valid TimeSpan value (FromSeconds, FromMinutes, etc.) to the values that work for you.

More to Come

This is the the first iteration of this library. Future expansions will allow you to selectively apply throttling on specific controller actions through the use of attributes.