EricksonLopez.RateLimiting
dotnet-ratelimiting · Reliability & Concurrency
On this page (20 sections)
1. Identity, Tier & Maturity Profile#
2. Value Proposition & Problem Solved#
Zero-allocation rate limiting engine & ASP.NET Core middleware for .NET 8/9/10. In-memory & distributed Redis Lua algorithms with Native AOT & Fail-Open resilience.
In-memory System.Threading.RateLimiting counters multiply tenant quotas across Kubernetes replicas and allocate RateLimitLease class instances on hot paths.
3. Quick Install#
Primary package: EricksonLopez.RateLimiting
dotnet add package EricksonLopez.RateLimiting --version 1.0.0<PackageReference Include="EricksonLopez.RateLimiting" Version="1.0.0" /><PackageVersion Include="EricksonLopez.RateLimiting" Version="1.0.0" />4. Verified Ecosystem Metrics#
Snapshot retrieved UTC: 2026-12-01
5. When to Use & When Not to Use#
When to use
- You want distributed atomic Redis Lua rate limiters (Sliding Window, Token Bucket, Fixed Window, Concurrency) with Result-based Fail-Open/Fail-Closed posture.
When NOT to use
- Edge CDN / Cloudflare WAF rate limiting handles all throttling before traffic ever reaches your .NET process.
6. Core Capabilities & Design Invariants#
Value-Type RateLimitLease & Algorithms
Struct RateLimitLease plus SlidingWindow, TokenBucket, FixedWindow, Concurrency, and Composite limiters.
Atomic Redis Lua & ASP.NET Core
Single round-trip Redis Lua execution, DefensiveLockout brute-force protection, and HTTP middleware.
7. Included NuGet Packages & Adapters#
| Package ID | Status | NuGet / Local | TFMs | AOT Status | Downloads | Description |
|---|---|---|---|---|---|---|
| EricksonLopez.RateLimitingPrimary | Published | v1.0.0 / v2.0.0 | net8.0, net9.0, net10.0 | AOT: Full | 181 | High-throughput rate limiting engine for .NET. Features sliding window, token bucket, fixed window algorithms with zero allocations and Native AOT compatibility. |
| EricksonLopez.RateLimiting.Redis | Published | v1.0.0 / v2.0.0 | net8.0, net9.0, net10.0 | AOT: Full | 148 | Distributed Redis-backed rate limiters for EricksonLopez.RateLimiting. Implements Sliding Window (atomic Lua script over Redis ZSET) and Token Bucket (atomic Lua script over Redis Hash) distributed algorithms for consistent rate limiting behavior across multiple horizontally-scaled application instances. Native AOT-compatible compatible. |
| EricksonLopez.RateLimiting.AspNetCore | Published | v1.0.0 / v2.0.0 | net8.0, net9.0, net10.0 | AOT: Full | 132 | ASP.NET Core middleware and endpoint integration for EricksonLopez.RateLimiting. Emits standard rate limit headers and enforces 429 Too Many Requests responses. |
8. Quick Start Code Example#
Grounded in verified public APIs from EricksonLopez.RateLimiting. Compile with `<ImplicitUsings>disable</ImplicitUsings>` and explicit imports.
using System;
using EricksonLopez.RateLimiting;
var options = new RateLimiterOptions
{
PermitLimit = 100,
Window = TimeSpan.FromMinutes(1),
SegmentsPerWindow = 6
};
var limiter = new SlidingWindowRateLimiter(options);
var leaseResult = await limiter.AcquireAsync("tenant-123", permits: 1);
if (leaseResult.IsSuccess && leaseResult.Value.IsAcquired)
{
using var lease = leaseResult.Value;
Console.WriteLine("Permit acquired.");
}9. Architecture & Dependency Flow#
Rendering diagram…
flowchart LR lib_ratelimiting["EricksonLopez.RateLimiting (L2)"] lib_result["EricksonLopez.Result (L0)"] lib_ratelimiting --> lib_result
View accessible text summary and structure
1 upstream library dependencies and 0 downstream dependent libraries verified in dependencies.json.
| Direction | Library | Tier | Relationship Kinds |
|---|---|---|---|
| Upstream | EricksonLopez.Result | L0 | Compile-Time, NuGet Package |
flowchart LR
lib_ratelimiting["EricksonLopez.RateLimiting (L2)"]
lib_result["EricksonLopez.Result (L0)"]
lib_ratelimiting --> lib_result10. Target Frameworks & Native AOT / Trimming Matrix#
MSBuild `.csproj` inspection across 3 packages: 3 Full, 0 Partial, 0 Incompatible, 0 NotApplicable (analyzers/generators).
| Package ID | IsAotCompatible | EnableTrimAnalyzer | Verified AOT Status | Target Frameworks |
|---|---|---|---|---|
| EricksonLopez.RateLimiting | true | true | Full | net8.0, net9.0, net10.0 |
| EricksonLopez.RateLimiting.Redis | true | true | Full | net8.0, net9.0, net10.0 |
| EricksonLopez.RateLimiting.AspNetCore | true | true | Full | net8.0, net9.0, net10.0 |
11. Upstream Dependencies & Downstream Dependents#
Upstream Dependencies (1)
Downstream Dependents (0)
No other EricksonLopez.* libraries currently depend on this family.
12. Optional Adapters & Third-Party Integrations#
Internal Adapter Edges & Integration Packages
No optional cross-family adapter edges or integration packages are recorded for this library.
Verified External NuGet Dependencies (4)
13. Configuration & DI Registration Summary#
Verified DI & Configuration Entry Points
RateLimitingServiceCollectionExtensions.AddCompositeRateLimiterRegisters the `CompositeRateLimiter` as the default `IRateLimiter` service.
RateLimitingServiceCollectionExtensions.AddConcurrencyRateLimiterRegisters the `ConcurrencyRateLimiter` as the default `IRateLimiter` service.
RateLimitingServiceCollectionExtensions.AddFixedWindowRateLimiterRegisters the `FixedWindowRateLimiter` as the default `IRateLimiter` service.
RateLimitingServiceCollectionExtensions.AddInMemoryDefensiveLockoutRegisters `InMemoryDefensiveLockoutStore` as the `IDefensiveLockoutStore` service.
RateLimitingServiceCollectionExtensions.AddSlidingWindowRateLimiterRegisters the `SlidingWindowRateLimiter` as the default `IRateLimiter` service.
RateLimitingServiceCollectionExtensions.AddTokenBucketRateLimiterRegisters the `TokenBucketRateLimiter` as the default `IRateLimiter` service.
RateLimitingAspNetCoreExtensions.AddDefensiveLockoutRegisters defensive lockout options and a default `InMemoryDefensiveLockoutStore` (if no distributed `IDefensiveLockoutStore` is registered).
RateLimitingAspNetCoreExtensions.AddHttpRateLimitingConfigures HTTP rate limiting options in Microsoft Dependency Injection.
RateLimitingAspNetCoreExtensions.AddRateLimitingRegisters named rate limiting policies using a fluent builder and configures middleware services.
RateLimitingAspNetCoreExtensions.UseDefensiveLockoutAdds `DefensiveLockoutMiddleware` into the application request execution pipeline.
RateLimitingAspNetCoreExtensions.UseHttpRateLimitingAdds `RateLimitingMiddleware` into the application request execution pipeline.
RateLimiterPolicyBuilder.AddCompositeConfigures and registers a composite rate limiting policy evaluated with conjunction logic.
Key Public Types & Contracts
EricksonLopez.RateLimiting.ClientIpNormalizer (class)Provides canonical, allocation-conscious client IP normalization across HTTP sockets and gRPC peer strings.
EricksonLopez.RateLimiting.CompositeRateLimiter (class)Evaluates multiple child rate limiters in sequential order using conjunction logic.
EricksonLopez.RateLimiting.ConcurrencyRateLimiter (class)Controls the number of concurrent in-flight operations permitted per partition key.
EricksonLopez.RateLimiting.ConcurrencyRateLimiterOptions (class)Specifies configuration options for `ConcurrencyRateLimiter`.
EricksonLopez.RateLimiting.DefensiveLockoutOptions (class)Specifies configuration options for perimeter defensive lockout protection against brute-force and credential-stuffing sweeps.
EricksonLopez.RateLimiting.FixedWindowRateLimiter (class)Controls request rates using an in-memory discrete fixed time window algorithm.
EricksonLopez.RateLimiting.IDefensiveLockoutStore (interface)Defines a thread-safe persistence store for tracking failed authentication bursts and enforcing defensive lockouts across single or distributed application nodes.
EricksonLopez.RateLimiting.IRateLimiter (interface)Defines rate limiting capabilities for concurrency and throughput throttling.
EricksonLopez.RateLimiting.InMemoryDefensiveLockoutStore (class)Provides a thread-safe, bounded in-memory implementation of `IDefensiveLockoutStore` driven by `TimeProvider`.
EricksonLopez.RateLimiting.LockoutStatus (record)Represents the current defensive lockout evaluation state for a tracked client or device key.
EricksonLopez.RateLimiting.RateLimitLease (record)Represents the result of an attempt to acquire permits from a rate limiter.
EricksonLopez.RateLimiting.RateLimiterOptions (class)Specifies configuration options for time-windowed rate limiters.
14. Verified Performance Benchmarks#
All verified measurements below come strictly from `BenchmarkDotNet.Artifacts` running on .NET RyuJIT (0 NativeAOT benchmark runs exist in this snapshot).
| Suite | Method | Runtime | Mean (ns) | Allocated (B) | Status |
|---|---|---|---|---|---|
| RateLimiterHotPathBenchmarks | EricksonLopez_RateLimitLease_Struct_ZeroAllocation | .NET 10.0.11 X64 RyuJIT x86-64-v4 | 0 | 0 | measured |
| RateLimiterHotPathBenchmarks | BCL_TokenBucket_AttemptAcquire | .NET 10.0.11 X64 RyuJIT x86-64-v4 | 15.916 | 40 | measured |
| RateLimiterHotPathBenchmarks | EricksonLopez_FixedWindow_AcquireAsync | .NET 10.0.11 X64 RyuJIT x86-64-v4 | 193.684 | 184 | measured |
| RateLimiterHotPathBenchmarks | EricksonLopez_SlidingWindow_AcquireAsync | .NET 10.0.11 X64 RyuJIT x86-64-v4 | 203.967 | 184 | measured |
| RateLimiterHotPathBenchmarks | EricksonLopez_TokenBucket_AcquireAsync | .NET 10.0.11 X64 RyuJIT x86-64-v4 | 208.012 | 184 | measured |
15. Release History & NuGet vs Repo Status#
Version lag detected: NuGet.org latest published version is v1.0.0, while local repository HEAD is at v2.0.0.
| Version | Source | Published Date | Summary |
|---|---|---|---|
| v1.0.0 ↗ | github | 2026-09-22 | Ecosystem Packages in this release | Package | Version | |---------|---------| | `EricksonLopez.RateLimiting` | `1.0.0` | | `EricksonLopez.RateLimiting.AspNetCore` | `1.0.0` | | `EricksonLopez.RateLimiting.Redis` | `1.0.0` | --- For detailed changes, see [CHANGELOG.md](https://github.com/ericksonlopezf/dotnet-ratelimiting/blob/v1.0.0/CHANGELOG.md). |
| v1.0.0 ↗ | nuget | 2026-09-22 | Published EricksonLopez.RateLimiting 1.0.0 to NuGet.org. |
16. Complementary & Related Libraries#
Libraries in the same tier, architectural layer, or directly paired via dependency edges.
17. Documentation, API Reference & Portal Links#
Conceptual Documentation (Starlight) →
Extracted XML API Reference →
4 namespaces · 39 types · 156 members
Ecosystem Dependency Map →
Learning Center & Handbook →
Per-library conceptual Starlight pages expand in M4; API Reference pages expand in M3.2.
18. Source Repository, License & Contributing#
Released under the MIT License. All assemblies follow EricksonLopez.* build invariants: explicit imports, strong-name signing (`EricksonLopez.snk`), and ASCII author metadata (`Erickson Lopez`).
19. Troubleshooting, Pitfalls & Migration Guidance#
- Notice all 3 packages in this family are IsAotCompatible=true and EnableTrimAnalyzer=true.
- Version lag detected: NuGet.org latest published version is v1.0.0, while local repository HEAD is at v2.0.0.
20. Quality & Verification Evidence#
- Strong-Name Signing (`EricksonLopez.snk`)
- EricksonLopez.snk
- `ImplicitUsings=disable`
- disable
- XML Documentation Extraction
- Verified (4 namespaces, 39 types, 156 members)
- MSBuild AOT / Trim Attributes
- 3 Full / 0 Partial / 0 Incompatible / 0 N/A
- BenchmarkDotNet Artifacts
- 5 total (5 measured, 0 na_error)
Explicit Verification Boundaries & Limitations
- All verified measurements below come strictly from `BenchmarkDotNet.Artifacts` running on .NET RyuJIT (0 NativeAOT benchmark runs exist in this snapshot).