⚙️ Asp.Net Core: Fix Kestrel Capping Concurrent HTTP/2 Streams
Kestrel’s HTTP/2 transport enforces a maximum number of concurrent streams per connection (Limits.Http2.MaxStreamsPerConnection, defaulting to 100), and a client that multiplexes many simultaneous requests over a single long-lived HTTP/2 connection — a gRPC client with aggressive parallel streaming calls, or a browser making a burst of concurrent fetches that all happen to reuse the same negotiated connection — can hit that cap under real load even though the server has plenty of spare CPU and memory. Once the cap is hit, Kestrel doesn’t queue the excess streams for that connection; the client-side library has to either wait for an existing stream to close or open a brand-new connection, and depending on the client’s retry/backoff behavior, that can surface as request timeouts that look like a server-side performance problem rather than a connection-level concurrency ceiling.
🔎 The Problem
// Default Kestrel HTTP/2 configuration - no explicit stream limit set
builder.WebHost.ConfigureKestrel(options =>
{
options.ListenAnyIP(5001, listenOptions => listenOptions.UseHttps());
// Limits.Http2.MaxStreamsPerConnection defaults to 100
});
// A gRPC client opening 150+ concurrent streaming calls over one
// shared channel starts seeing calls queue or fail past stream 100,
// even though server CPU is sitting under 20% utilization the entire
// time - the bottleneck is the per-connection stream cap, not capacity
✅ Fix: Size the Stream Limit to Match Real Client Concurrency
- Raise
Limits.Http2.MaxStreamsPerConnectionexplicitly to a value that comfortably covers your heaviest client’s actual peak concurrent stream count, rather than leaving the conservative default in place and discovering the ceiling only under real production load. - For a gRPC-heavy service specifically, consider whether the client should instead be spreading load across multiple separate channels/connections rather than relying on one connection to carry an unbounded number of concurrent streams — this also protects against a single misbehaving connection dominating the server’s resources.
- Monitor Kestrel’s HTTP/2 stream-level metrics in production (available through
Microsoft.AspNetCore.Server.Kestrelevent counters) rather than inferring the stream cap is the bottleneck purely from symptoms — request timeouts under low CPU usage have several other possible causes, and confirming the actual limit being hit avoids tuning the wrong setting.
🚨 Why This Is Dangerous
- A request that appears to simply time out gives no direct indication that the real cause is a per-connection concurrency cap rather than slow application code, so it’s easy to spend time profiling and optimizing business logic that was never actually the bottleneck, while the one-line Kestrel configuration change that would have fixed it goes unconsidered.
Kestrel’s HTTP/2 stream limit isn’t a performance setting you’ll ever notice until a client’s concurrency pattern grows past it — and when it does, every symptom it produces looks exactly like a slow server that isn’t actually slow.




