SmartRateLimiter.NET
1.0.0
dotnet add package SmartRateLimiter.NET --version 1.0.0
NuGet\Install-Package SmartRateLimiter.NET -Version 1.0.0
<PackageReference Include="SmartRateLimiter.NET" Version="1.0.0" />
<PackageVersion Include="SmartRateLimiter.NET" Version="1.0.0" />
<PackageReference Include="SmartRateLimiter.NET" />
paket add SmartRateLimiter.NET --version 1.0.0
#r "nuget: SmartRateLimiter.NET, 1.0.0"
#:package SmartRateLimiter.NET@1.0.0
#addin nuget:?package=SmartRateLimiter.NET&version=1.0.0
#tool nuget:?package=SmartRateLimiter.NET&version=1.0.0
๐ SmartRateLimiter.NET
A plug & play, production-ready rate limiting library for ASP.NET Core.
Supports multiple algorithms, storage strategies, and distributed systems.
โจ Features
โก Multiple algorithms:
- Sliding Window (default)
- Fixed Window
- Token Bucket
๐ข In-Memory support (fast, simple)
๐ด Redis support (distributed systems)
๐ฅ Hybrid mode (Memory + Redis + fallback)
๐ฏ Attribute-based per-endpoint control
๐งฉ Middleware integration
๐ Swagger UI integration
๐ง Clean architecture (Strategy Pattern)
๐ฆ Installation
dotnet add package SmartRateLimiter.NET
โ๏ธ Quick Start
Program.cs
builder.Services.AddSmartRateLimiter(options =>
{
options.DefaultLimit = 5;
options.DefaultWindowSeconds = 10;
});
app.UseSmartRateLimiter();
๐ Storage Modes
๐ข In-Memory (Default)
builder.Services.AddSmartRateLimiter();
โ Fast โ Not shared across instances
๐ด Redis (Distributed)
builder.Services.AddSmartRateLimiterWithRedis("localhost:6379");
โ Shared across multiple instances โ Production ready
๐ฅ Hybrid (Recommended for Scale)
builder.Services.AddSmartRateLimiterHybrid("localhost:6379");
โ Fast (memory) โ Distributed (Redis) โ Resilient (fallback if Redis fails)
๐ฏ Usage (Per Endpoint)
[RateLimit(Type = RateLimitType.SlidingWindow, Limit = 5, WindowSeconds = 10)]
[HttpGet("users")]
public IActionResult GetUsers()
{
return Ok();
}
๐ Algorithms
Sliding Window
[RateLimit(Type = RateLimitType.SlidingWindow, Limit = 5, WindowSeconds = 10)]
Fixed Window
[RateLimit(Type = RateLimitType.FixedWindow, Limit = 10, WindowSeconds = 60)]
Token Bucket
[RateLimit(Type = RateLimitType.TokenBucket, Capacity = 10, RefillRate = 2, IntervalSeconds = 5)]
๐ค Response When Limit Exceeded
HTTP 429 Too Many Requests
๐งฑ Architecture
Client Request
โ
RateLimiter Middleware
โ
Strategy Resolver
โ
Algorithm Strategy
โ
Store (Memory / Redis / Hybrid)
โ
Allow / Reject
๐งช Demo Project
A working demo is available in /demo folder.
Run:
cd demo/SmartRateLimiter.Demo
dotnet run
Open Swagger:
https://localhost:xxxx/swagger
โ๏ธ Config-Based Mode Switching
{
"RateLimiter": {
"Mode": "Hybrid",
"RedisConnection": "localhost:6379"
}
}
๐ก Real Use Cases
- ๐ Login APIs (strict rate limiting)
- ๐ Product APIs (moderate limits)
- ๐ณ Payment APIs (smooth burst handling)
- ๐ก Public APIs (abuse protection)
๐ Tech Stack
- .NET 8
- ASP.NET Core Middleware
- Redis (StackExchange.Redis)
- Swagger (Swashbuckle)
๐ Roadmap
- Response headers (X-RateLimit-Remaining)
- Retry-After header
- Metrics & logging
- Dashboard UI
- API key-based rate limiting
๐ค Contributing
Pull requests welcome.
๐ License
MIT License
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. 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. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- StackExchange.Redis (>= 2.12.14)
- Swashbuckle.AspNetCore (>= 10.1.7)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0 | 101 | 4/12/2026 |