EricksonLopez.RateLimiting

dotnet-ratelimiting · Reliability & Concurrency

On this page (20 sections)

1. Identity, Tier & Maturity Profile#

L2 Cross-Cutting & ReliabilityStableMaintenance: ActiveAOT: FullMIT LicenseConfidence: HIGH
Cross-CuttingPresentationnet8.0net9.0net10.0

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
Also published in this family:
EricksonLopez.RateLimiting.RedisEricksonLopez.RateLimiting.AspNetCore

4. Verified Ecosystem Metrics#

v1.0.0
NuGet Published Version
v2.0.0
Repo HEAD Version
461
NuGet Downloads
3
Packable Packages
156
Public API Members
5
Benchmark Rows (RyuJIT)

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 IDStatusNuGet / LocalTFMsAOT StatusDownloadsDescription
EricksonLopez.RateLimitingPrimaryPublishedv1.0.0 / v2.0.0net8.0, net9.0, net10.0AOT: Full181High-throughput rate limiting engine for .NET. Features sliding window, token bucket, fixed window algorithms with zero allocations and Native AOT compatibility.
EricksonLopez.RateLimiting.RedisPublishedv1.0.0 / v2.0.0net8.0, net9.0, net10.0AOT: Full148Distributed 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.AspNetCorePublishedv1.0.0 / v2.0.0net8.0, net9.0, net10.0AOT: Full132ASP.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#

flowchart LR
  lib_ratelimiting["EricksonLopez.RateLimiting (L2)"]
  lib_result["EricksonLopez.Result (L0)"]
  lib_ratelimiting --> lib_result
EricksonLopez.RateLimiting Dependency Topology1 upstream library dependencies and 0 downstream dependent libraries verified in dependencies.json.
View accessible text summary and structure

1 upstream library dependencies and 0 downstream dependent libraries verified in dependencies.json.

DirectionLibraryTierRelationship Kinds
UpstreamEricksonLopez.ResultL0Compile-Time, NuGet Package
flowchart LR
  lib_ratelimiting["EricksonLopez.RateLimiting (L2)"]
  lib_result["EricksonLopez.Result (L0)"]
  lib_ratelimiting --> lib_result

10. Target Frameworks & Native AOT / Trimming Matrix#

MSBuild `.csproj` inspection across 3 packages: 3 Full, 0 Partial, 0 Incompatible, 0 NotApplicable (analyzers/generators).

Package IDIsAotCompatibleEnableTrimAnalyzerVerified AOT StatusTarget Frameworks
EricksonLopez.RateLimitingtruetrueFullnet8.0, net9.0, net10.0
EricksonLopez.RateLimiting.RedistruetrueFullnet8.0, net9.0, net10.0
EricksonLopez.RateLimiting.AspNetCoretruetrueFullnet8.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)

Microsoft.Extensions.DependencyInjection.AbstractionsMicrosoft.Extensions.Logging.AbstractionsMicrosoft.Extensions.OptionsStackExchange.Redis

13. Configuration & DI Registration Summary#

Verified DI & Configuration Entry Points

  • RateLimitingServiceCollectionExtensions.AddCompositeRateLimiter

    Registers the `CompositeRateLimiter` as the default `IRateLimiter` service.

  • RateLimitingServiceCollectionExtensions.AddConcurrencyRateLimiter

    Registers the `ConcurrencyRateLimiter` as the default `IRateLimiter` service.

  • RateLimitingServiceCollectionExtensions.AddFixedWindowRateLimiter

    Registers the `FixedWindowRateLimiter` as the default `IRateLimiter` service.

  • RateLimitingServiceCollectionExtensions.AddInMemoryDefensiveLockout

    Registers `InMemoryDefensiveLockoutStore` as the `IDefensiveLockoutStore` service.

  • RateLimitingServiceCollectionExtensions.AddSlidingWindowRateLimiter

    Registers the `SlidingWindowRateLimiter` as the default `IRateLimiter` service.

  • RateLimitingServiceCollectionExtensions.AddTokenBucketRateLimiter

    Registers the `TokenBucketRateLimiter` as the default `IRateLimiter` service.

  • RateLimitingAspNetCoreExtensions.AddDefensiveLockout

    Registers defensive lockout options and a default `InMemoryDefensiveLockoutStore` (if no distributed `IDefensiveLockoutStore` is registered).

  • RateLimitingAspNetCoreExtensions.AddHttpRateLimiting

    Configures HTTP rate limiting options in Microsoft Dependency Injection.

  • RateLimitingAspNetCoreExtensions.AddRateLimiting

    Registers named rate limiting policies using a fluent builder and configures middleware services.

  • RateLimitingAspNetCoreExtensions.UseDefensiveLockout

    Adds `DefensiveLockoutMiddleware` into the application request execution pipeline.

  • RateLimitingAspNetCoreExtensions.UseHttpRateLimiting

    Adds `RateLimitingMiddleware` into the application request execution pipeline.

  • RateLimiterPolicyBuilder.AddComposite

    Configures 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).

Total rows: 5 · Measured: 5 · NA / Error: 0 · Suites: 1

Observed runtimes: .NET 10.0.11 X64 RyuJIT x86-64-v4

Observed CPUs: AMD Ryzen 7 9800X3D 4.70GHz, 1 CPU, 8 logical and 8 physical cores

SuiteMethodRuntimeMean (ns)Allocated (B)Status
RateLimiterHotPathBenchmarksEricksonLopez_RateLimitLease_Struct_ZeroAllocation.NET 10.0.11 X64 RyuJIT x86-64-v400measured
RateLimiterHotPathBenchmarksBCL_TokenBucket_AttemptAcquire.NET 10.0.11 X64 RyuJIT x86-64-v415.91640measured
RateLimiterHotPathBenchmarksEricksonLopez_FixedWindow_AcquireAsync.NET 10.0.11 X64 RyuJIT x86-64-v4193.684184measured
RateLimiterHotPathBenchmarksEricksonLopez_SlidingWindow_AcquireAsync.NET 10.0.11 X64 RyuJIT x86-64-v4203.967184measured
RateLimiterHotPathBenchmarksEricksonLopez_TokenBucket_AcquireAsync.NET 10.0.11 X64 RyuJIT x86-64-v4208.012184measured

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.

VersionSourcePublished DateSummary
v1.0.0 ↗github2026-09-22Ecosystem 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 ↗nuget2026-09-22Published EricksonLopez.RateLimiting 1.0.0 to NuGet.org.

Libraries in the same tier, architectural layer, or directly paired via dependency edges.

17. Documentation, API Reference & Portal Links#

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).

Search EricksonLopez.* Ecosystem

Type a library name, NuGet package ID, .NET type, or architectural concept to search across the portal.