-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Threadpool doesn't scale optimally at low thread count #46077
Comments
/cc @kouvel |
An issue I'm aware of in CPU-limited environments is that hill climbing does not work very well in low-thread-count situations, and can be more intrusive than helpful. It can be disabled by starting the process with environment variable |
With the idle thread and hill climbing disabled, CPU is at 50% and the server processes 84,000 requests per 10 second (down from 99,000 requests with hill climbing). Without the idle thread, CPU is at 98% and the server processes 105,000 requests per 10 seconds (down from 110,000 requests with hill climbing). |
Sounds like hill climbing is not compensating for the blocked thread (at least soon enough). I'll try to get a repro. It should be possible and perhaps better to have the starvation heuristic track starvation on a per-thread basis rather than for the whole pool of worker threads. |
I ran into a weird performance issue where having one idle threadpool thread impacted significantly the throughput of the application.
The minimum repro is a simple ASP.NET Core MVC app (
dotnet new mvc
) running on a 2 cores instance (Amazon c5.large). When load-testing the/home
endpoint with enough traffic to overload the server, I get the following results:Now if I modify the application and use one threadpool worker for some idle work:
I then get the following results:
The size of the threadpool didn't change despite the wasted worker, and now the server is unable to fully use the CPU to process the requests.
I know that long-running work shouldn't be pushed to the threadpool, but that's a common mistake and I was expecting the number of workers to be adjusted accordingly.
Metrics are measured using dotnet-counters:
dotnet-counters monitor System.Runtime Microsoft.AspNetCore.Hosting --refresh-interval 10 -p 23328
I initially ran into this with .NET Core 3.1.9, but could reproduce with .NET 5.0.1.
The text was updated successfully, but these errors were encountered: