Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/nimanikoo/Dotnet-RateLimiter/llms.txt

Use this file to discover all available pages before exploring further.

Dotnet-RateLimiter is a production-ready distributed rate limiting framework for .NET 10 applications. By offloading rate limit logic to Redis via atomic Lua scripting, it eliminates race conditions that plague standard in-memory limiters in multi-instance deployments — giving you consistent, cluster-wide enforcement with a single attribute.

Quickstart

Add distributed rate limiting to your .NET 10 API in minutes with a single attribute.

Deploy with Docker

Spin up the full stack — API, Redis, and monitoring — with one Docker Compose command.

Rate Limiting Strategies

Explore Fixed Window, Sliding Window, Token Bucket, and Concurrency strategies.

API Reference

Full reference for all public classes, methods, and extension points.

Why Dotnet-RateLimiter?

In a distributed environment, multiple API instances each maintain independent state. Standard in-memory limiters allow race conditions — two servers can both see a counter of 9 (at a limit of 10) and both allow the request, silently exceeding your limit. Dotnet-RateLimiter solves this by executing all limit logic atomically inside Redis.

Atomic Lua Scripting

Every increment and check runs as a single Redis transaction — no race conditions, guaranteed consistency.

Identity-Aware

Authenticated users are tracked by User ID; anonymous guests by client IP. Limits are scoped per user and per path.

One-Attribute Integration

Protect any endpoint with [RedisRateLimit(maxRequests: 10, windowSeconds: 60)] — nothing else required.

Five Strategies

Distributed Redis Fixed Window, Fixed Window, Sliding Window, Token Bucket, and Concurrency Limiter.

Health Monitoring

Built-in /health-ui dashboard with real-time Redis connectivity, latency, and liveness checks.

Docker Ready

Full Docker Compose stack with RedisInsight for live key and TTL inspection out of the box.

Get Started in 3 Steps

1

Register services

Call AddCustomRateLimiter in Program.cs to register Redis, all policies, and health checks in one call.
Program.cs
builder.Services.AddCustomRateLimiter(builder.Configuration);
2

Configure Redis

Set your Redis connection string in appsettings.json.
appsettings.json
{
  "Redis": {
    "ConnectionString": "localhost:6379,abortConnect=false"
  }
}
3

Protect your endpoints

Apply [RedisRateLimit] to any controller action to enforce distributed rate limiting.
[HttpGet("data")]
[RedisRateLimit(maxRequests: 10, windowSeconds: 60)]
public IActionResult GetData() => Ok("Protected by atomic Redis logic.");
Dotnet-RateLimiter targets .NET 10 and requires a running Redis instance. Use the included compose.yaml to start the full stack locally with no extra setup.

Build docs developers (and LLMs) love