The FixedWindowPolicy is one of the four in-memory rate-limiting policies registered in Dotnet-RateLimiter via ASP.NET Core’s built-inDocumentation 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.
AddRateLimiter infrastructure. It uses a simple counter that resets at the end of each fixed time window. Because the counter lives in process memory, this policy is ideal for single-node deployments, local development, and integration testing — situations where distributed consistency across multiple application instances is not a requirement.
Registration
The policy is registered insideAddCustomRateLimiter in RateLimiterExtensions.cs:
| Option | Value | Meaning |
|---|---|---|
Window | 5 seconds | Duration of each fixed time window |
PermitLimit | 5 | Maximum requests allowed per window |
QueueLimit | 10 | Maximum requests that can wait in the queue beyond the limit |
QueueProcessingOrder | OldestFirst | Queued requests are processed in first-in, first-out order |
RejectionStatusCode | 429 | HTTP status returned when both the limit and queue are full |
Applying the Policy
Decorate any controller action with[EnableRateLimiting("FixedWindowPolicy")] to opt that endpoint into the policy. From TestController.cs:
"FixedWindowPolicy").
How the Queue Works
When the number of active requests reachesPermitLimit (5), additional requests are not immediately rejected — they are held in a queue up to QueueLimit (10).
QueueProcessingOrder.OldestFirst, the request that has been waiting the longest is the first to be released when capacity becomes available at the start of the next window. This prevents newer requests from jumping ahead of older ones, which is the fairest behaviour for most REST APIs.
When to Use
| Scenario | Recommendation |
|---|---|
| Single-node application or local development | ✅ FixedWindowPolicy is appropriate |
| Unit/integration tests that need rate limiting | ✅ No Redis dependency required |
| Kubernetes or multi-replica cloud deployment | ❌ Use the Redis Fixed Window instead |
| Need smoother request distribution over time | Consider SlidingWindowPolicy |
