Skip to main content
The rate limiter strategy controls the rate of executions to prevent resource exhaustion and ensure fair usage.

RateLimiterStrategyOptions

Configures the rate limiter resilience strategy.

Properties

Func<RateLimiterArguments, ValueTask<RateLimitLease>>?
default:"null"
A rate limiter delegate that produces RateLimitLease instances.If null, the strategy uses a ConcurrencyLimiter created with DefaultRateLimiterOptions.
ConcurrencyLimiterOptions
required
The default rate limiter options used when RateLimiter is null.Default configuration:
  • PermitLimit: 1000
  • QueueLimit: 0
Func<OnRateLimiterRejectedArguments, ValueTask>?
default:"null"
An event raised when the execution of a user-provided callback is rejected by the rate limiter.

Extension Methods

Add rate limiter strategies to a resilience pipeline:

Usage Examples

Using Default Concurrency Limiter

Using Custom Rate Limiter

Sliding Window Rate Limiter

Built-in Rate Limiters

.NET provides several built-in rate limiters in the System.Threading.RateLimiting namespace:
  • ConcurrencyLimiter: Limits the number of concurrent executions
  • TokenBucketRateLimiter: Token bucket algorithm
  • SlidingWindowRateLimiter: Sliding window algorithm
  • FixedWindowRateLimiter: Fixed window algorithm