Class ConcurrencyLimitOptions
Per-registration admission limit for one route on the shared Kestrel host. Kestrel itself
accepts an unbounded number of concurrent requests; this caps how many of them may EXECUTE
a given route's handler at once, sheds the overflow with an immediate status reply
(load shedding, not backpressure — the industry norm: ASP.NET ConcurrencyLimiter policies,
nginx limit_conn, Envoy max_concurrent_requests), and leaves every other registration on the
same listener untouched.
Backed by : up to permits,
an optional FIFO wait queue of , everything beyond answered with
+ Retry-After before any pipeline work happens.
public sealed class ConcurrencyLimitOptions
Inheritance
Properties
MaxConcurrentRequests
Maximum concurrent executions of the route handler. Must be at least 1.
public required int MaxConcurrentRequests { get; init; }
OnRejected
Invoked once per shed request, before the reject response is written. The hosting layer
public Action? OnRejected { get; init; }
RejectStatusCode
Status code for a shed request. Default 429 Too Many Requests.
public int RejectStatusCode { get; init; }
RequestQueueLimit
How many requests over the limit WAIT for a permit (FIFO) instead of being rejected.
public int RequestQueueLimit { get; init; }
RetryAfterSeconds
Value of the Retry-After header on a shed request; 0 = do not send it. Default 1.
public int RetryAfterSeconds { get; init; }
Methods
FromEndpoint(int, int, int, int, Action?)
Builds the registration-level limit from endpoint options, or null when the feature is off
public static ConcurrencyLimitOptions? FromEndpoint(int maxConcurrentRequests, int requestQueueLimit, int rejectStatusCode, int retryAfterSeconds, Action? onRejected)
ValidateShape(int, int, int, int)
Validates the option quartet as it appears on an ENDPOINT, where 0 for
public static void ValidateShape(int maxConcurrentRequests, int requestQueueLimit, int rejectStatusCode, int retryAfterSeconds)