Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which component is handling thread allocation in ASP.NET Core?

In previous versions of asp.net the framework was responsible for allocating all the threads from thread pool and there was a configuration in the web.config to set it up (maximum number of threads, etc.). So which component is responsible for it in the new ASP.NET? I have not found any special middleware for that, I guess that it should happen even before the middleware, maybe in Kestrel.

like image 544
Ilya Chernomordik Avatar asked Oct 26 '15 12:10

Ilya Chernomordik


People also ask

How does ASP.NET Core handle multiple requests?

ASP.NET Core apps should be designed to process many requests simultaneously. Asynchronous APIs allow a small pool of threads to handle thousands of concurrent requests by not waiting on blocking calls. Rather than waiting on a long-running synchronous task to complete, the thread can work on another request.

What is thread in ASP.NET Core?

ASP.NET MVC 5 for Beginners A thread is defined as the execution path of a program. Each thread defines a unique flow of control.

How many threads does ASP.NET Core use?

By default Dotnet sets this value as the number of hardware threads available based on the CPU setting — 16. This means after all 16 threads are in use and 5 new requests come in. Dotnet thread pool will wait 0.5 second for each request then check if a thread becomes free, if yes allots that to the request.


1 Answers

The threadpool is a CLR resource that can be configured directly in your Startup https://msdn.microsoft.com/en-us/library/system.threading.threadpool%28v=vs.110%29.aspx.

I think what you're actually asking about is configuring how many threads the servers will use to process requests, correct? See https://github.com/aspnet/KestrelHttpServer/blob/01e9101543906ffd39239efd2f7bb41dbd879902/src/Microsoft.AspNetCore.Server.Kestrel/KestrelServerOptions.cs#L90

like image 124
Tratcher Avatar answered Oct 20 '22 23:10

Tratcher