Skip to content

ASP.Net Core Thread Starvation in high load #45277

Open
@EikeSchwass

Description

@EikeSchwass

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

We are migrating a large code base from .Net Framework 4.7.2 ASP.NET to .NET 6 ASP.NET Core (Hosted in IIS 10).

Unfortunately we noticed a regression in high load scenarios. The ASP.NET was able to recover from load peaks, while ASP.NET Core enters thread starvation and only recovers if load is reduced and even then it takes minutes.
Due to Oracle not providing a true async API, a large part of our code base runs synchronously.

Our current hypothesis for the difference is the missing default request queue that was present in ASP.NET (?).
The naive approach would be to introduce a rate limiting middleware, but hard coding the number of concurrent requests that are allowed seems problematic. Is there a way to configure ASP.NET Core so that it starts to throttle/rate limit the number of requests as it approaches thread starvation?

We assume we would need something like this: https://referencesource.microsoft.com/#System.Web/RequestQueue.cs,8

Expected Behavior

ASP.NET Core should not allow overloading itself with requests and instead buffer them in that case similar how ASP.NET + IIS did it.

Steps To Reproduce

  1. Slowly increase load in ASP.NET WebApi until response timouts. Decrease load and observe how ASP.NET quickly recovers
  2. Slowly increase load in ASP.NET Core WebApi until response timouts. Decrease load and observe how ASP.NET Core stays unresponsive due to thread starvation for much longer

Exceptions (if any)

No response

.NET Version

6.0.403

Anything else?

We gathered some information from https://developercommunity.visualstudio.com/t/on-net-core-timeout-in-large-concurrency/693778#T-N694931

Metadata

Metadata

Assignees

Labels

DocsThis issue tracks updating documentationarea-networkingIncludes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractionsnet8_docathonThis issue is part of the documentation push in Fall 2023.

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions