Skip to content

RateLimitEngine v1.0.0

Latest

Choose a tag to compare

@peymanpro peymanpro released this 02 Sep 02:34
· 108 commits to main since this release

RateLimitEngine v1.0.0

The first stable release of RateLimitEngine, a production-oriented, extensible, and distributed rate-limiting library for .NET and ASP.NET Core.

RateLimitEngine is designed around a clear separation between rate-limiting algorithms, state storage, framework integration, and distributed execution, making it suitable for both single-instance and horizontally scaled applications.

Highlights

Multiple Rate-Limiting Algorithms

This release provides four rate-limiting algorithms:

  • Fixed Window

  • Sliding Window

  • Token Bucket

  • GCRA (Generic Cell Rate Algorithm)

Each algorithm is exposed through a common IRateLimiter abstraction while preserving algorithm-specific behavior and configuration.

In-Memory and Redis Backends

Rate-limiter state can be stored in:

  • In-memory storage for single-instance applications

  • Redis-backed storage for distributed and horizontally scaled deployments

Redis operations are implemented with atomic server-side scripts to keep state transitions consistent across concurrent application instances.

ASP.NET Core Integration

The library includes first-class ASP.NET Core middleware integration with support for:

  • Request rate limiting

  • Configurable rate-limit policies

  • Custom key resolution

  • Remote IP based limiting

  • Application-defined failure strategies

  • Integration with dependency injection

This allows rate limiting to be introduced without coupling the core engine to ASP.NET Core.

Flexible Rate-Limit Keys

The middleware can be used with different identity models, including scenarios such as:

  • Client IP addresses

  • Authenticated users

  • API keys

  • Tenants

  • Custom application-defined identities

The key resolution mechanism is intentionally extensible so applications can define their own rate-limit scope.

Concurrency-Focused Design

Concurrency correctness is a central design goal of the project.

The test suite includes dedicated concurrency scenarios with thousands of simultaneous operations against the rate-limiting implementations, helping validate behavior at the boundaries where race conditions and state inconsistencies are most likely to occur.

Distributed Consistency

The Redis implementation is designed for distributed deployments where multiple application instances share rate-limit state.

Atomic Redis scripting is used for state transitions so that concurrent requests from different instances do not rely on application-side locking.

Resilience Around Redis Operations

The Redis layer includes configurable retry behavior for transient script-execution failures, providing an explicit mechanism for handling temporary backend failures without hiding the distributed nature of the system.

Time Abstraction

Rate-limiting decisions are isolated from direct system-clock access through the IClock abstraction.

This keeps time-dependent behavior testable and allows deterministic testing of algorithms whose correctness depends on precise time progression.

Quality and Validation

The v1.0.0 codebase has been validated with a multi-layered test suite covering:

  • Unit tests

  • Concurrency tests

  • Integration tests

  • Distributed Redis tests

The current test suite contains 136 passing tests with zero failures in Release configuration.

The project also includes package-generation and validation steps in GitHub Actions to verify that the distributable packages are produced correctly.

Package Architecture

RateLimitEngine is split into focused packages:

Package | Purpose -- | -- RateLimitEngine.Core | Core abstractions, policies, decisions, contracts, and shared infrastructure RateLimitEngine.Algorithms | Rate-limiting algorithms and algorithm configuration RateLimitEngine.Redis | Redis-backed distributed state and Redis integration RateLimitEngine.AspNetCore | ASP.NET Core middleware and web integration

This modular design allows applications to depend only on the functionality they actually need.

Target Framework

  • .NET 8

Stability

v1.0.0 marks the first stable release of the public API and establishes the foundational architecture for using RateLimitEngine in real .NET applications.

The project intentionally prioritizes:

Correctness → Concurrency Safety → Distributed Consistency → Extensibility → Practical Integration

rather than maximizing the number of features.

Getting Started

Install the packages you need:

dotnet add package RateLimitEngine.Algorithms
dotnet add package RateLimitEngine.AspNetCore
dotnet add package RateLimitEngine.Redis

See the repository README for configuration examples and usage patterns.

License

RateLimitEngine is released under the MIT License.


Full source: https://github.com/peymanpro/RateLimitEngine