FireflySoft.RateLimit.Core 3.0.1

dotnet add package FireflySoft.RateLimit.Core --version 3.0.1                
NuGet\Install-Package FireflySoft.RateLimit.Core -Version 3.0.1                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="FireflySoft.RateLimit.Core" Version="3.0.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add FireflySoft.RateLimit.Core --version 3.0.1                
#r "nuget: FireflySoft.RateLimit.Core, 3.0.1"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install FireflySoft.RateLimit.Core as a Cake Addin
#addin nuget:?package=FireflySoft.RateLimit.Core&version=3.0.1

// Install FireflySoft.RateLimit.Core as a Cake Tool
#tool nuget:?package=FireflySoft.RateLimit.Core&version=3.0.1                



Fireflysoft.RateLimit is a rate limiting library based on .Net standard. Its core is simple and lightweight, and can flexibly meet the rate limiting needs of many scenarios.


  • Multiple rate limiting algorithms: built-in fixed window, sliding window, leaky bucket, token bucket, and can be extended.
  • Multiple counting storage: memory and Redis (including cluster).
  • Distributed friendly: supports unified counting of distributed programs with Redis storage.
  • Flexible rate limiting targets: each data can be extracted from the request to set rate limiting targets.
  • Support rate limit penalty: the client can be locked for a period of time after the rate limit is triggered.
  • Time window enhancement: support to the millisecond level; support starting from the starting point of time periods such as seconds, minutes, hours, dates, etc.
  • Real-time tracking: the number of requests processed and the remaining allowed requests in the current counting cycle, as well as the reset time of the counting cycle.
  • Dynamically change the rules: support the dynamic change of the rate limiting rules when the program is running.
  • Custom error: you can customize the error code and error message after the current limit is triggered.
  • Universality: in principle, it can meet any scenario that requires rate limiting.


If you need to use it in ASP.NET Core, it is recommended to install the package FireflySoft.RateLimit.AspNetCore.

Use IAlgorithm to filter every request, process the return value of Check method.

// Rule
var fixedWindowRules = new FixedWindowRule[]
        new FixedWindowRule()
            Id = "3",
            ExtractTarget = (request) =>
                return (request as SimulationRequest).RequestResource;
            CheckRuleMatching = (request) =>
                return true;

// Algorithm
IAlgorithm algorithm = new InProcessFixedWindowAlgorithm(fixedWindowRules);

// Check
var result = algorithm.Check(new SimulationRequest()
        RequestId = Guid.NewGuid().ToString(),
        RequestResource = "home",
        Parameters = new Dictionary<string, string>() {
                    { "from","sample" },

SimulationRequest is a custom request that you can modify to any type.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (3)

Showing the top 3 NuGet packages that depend on FireflySoft.RateLimit.Core:

Package Downloads

A rate limit library for ASP.NET Core.


A rate limit library for ASP.NET Core.


A rate limit library for ASP.NET.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
3.0.1 4,071 7/1/2022
3.0.0 6,008 7/1/2022
2.1.0 1,059 6/9/2022
2.0.2 1,143 11/4/2021
2.0.2-rc1 245 8/18/2021
2.0.1 1,764 6/19/2021
2.0.0 683 4/12/2021
1.3.0 390 3/21/2021
1.2.0 393 2/18/2021
1.0.1 1,256 1/24/2021
1.0.0 465 1/18/2021

1. Break change: Modify the Count returned by the token bucket algorithm to the cumulative number of visits in the current time window to be consistent with other algorithms.
2. Add a property 'Maintaining' to 'RuleCheckResult', which represents the number of remaining allowed requests in the current time window.
3. Add a property 'ResetTime' to 'RuleCheckResult', which represents the next reset time of the rate limit time window of the current algorithm.
4. Some other optimizations.