Skip to content
  • Home
  • About
  • No Access
  • Privacy Policy
Bits of .NET
Bits of .NET
  • C#
  • Asp.Net Core
  • SQL
  • Windows
  • WordPress
  • AI
  • JavaScript
  • CSS
  • MORE
    • HTML
    • Ajax
    • Git
    • Docker
    • Kubernetes
    • Photoshop
    • Visual Studio

Bits of .NET

Daily micro-tips for C#, SQL, performance, and scalable backend engineering.

  • C#
  • Asp.Net Core
  • SQL
  • Windows
  • WordPress
  • AI
  • JavaScript
  • CSS
  • MORE
    • HTML
    • Ajax
    • Git
    • Docker
    • Kubernetes
    • Photoshop
    • Visual Studio
Asp.Net Core

Asp.Net Core: Fix Kestrel Capping Concurrent HTTP/2 Streams

- 02.12.26 - ErcanOPAK

⚙️ 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.MaxStreamsPerConnection explicitly 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.Kestrel event 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.

— Backend Architect

Related posts:

Asp.Net Core: Fix an Options Reload Missing Its Validator

Asp.Net Core: Fix an Options Reload Missing Its Validator

.NET Core: Manage Configuration with appsettings

.NET Core: Manage Configuration with appsettings

EF Core: ExecuteUpdate & ExecuteDelete — Why You Should Stop Looping

EF Core: ExecuteUpdate & ExecuteDelete — Why You Should Stop Looping

Views: 0
Found this useful? Share it
XLinkedInWhatsApp

Post navigation

Visual Studio: Fix Container Tools Debugging Stuck Attaching
WordPress: Fix Taxonomy Term Counts Drifting After a Bulk Import

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Most Read

  1. 01How to make theater mode the default for Youtube 1,080 views
  2. 02How to add default value for Entity Framework migrations for DateTime and Bool 997 views
  3. 03Get the User Name and Domain Name from an Email Address in SQL 996 views
  4. 04Get the First and Last Word from a String or Sentence in SQL 873 views
  5. 05How to select distinct rows in a datatable in C# 869 views
  6. 06How to enable, disable and check if Service Broker is enabled on a database in SQL Server 672 views
  7. 07Add Constraint to SQL Table to ensure email contains @ 631 views
  8. 08Average of all values in a column that are not zero in SQL 585 views
  9. 09How to use Map Mode for Vertical Scroll Mode in Visual Studio 562 views
Bits of .NET

Daily micro-tips for C#, SQL, performance, and scalable backend engineering.

Social

  • ErcanOPAK.com
  • GoodReads
  • LetterBoxD
  • Linkedin
  • The Blog
  • Twitter
Back to top
© 2026 Bits of .NET | Built with Xblog Plus free WordPress theme by wpthemespace.com