Thread management in asp.net core / kestrel Thread management in asp.net core / kestrel azure azure

Thread management in asp.net core / kestrel


Is this expected behaviour - and if so is it just a case of making sure that no IO-bound work is done without using async code?

Based on my experience, it seems that is as expected behaviour. We could get answer from this blog.

Now suppose you are running your ASP.Net application on IIS and your web server has a total of four CPUs. Assume that at any given point in time, there are 100 requests to be processed. By default the runtime would create four threads, which would be available to service the first four requests. Because no additional threads will be added until 500 milliseconds have elapsed, the other 96 requests will have to wait in the queue. After 500 milliseconds have passed, a new thread is created.

As you can see, it will take 100*500ms intervals to catch up with the workload.

This is a good reason for using asynchronous programming. With async programming, threads aren’t blocked while requests are being handled, so the four threads would be freed up almost immediately.

I recommand that you could use async code to improve the performance.

public async Task<ActionResult> Wait1(){    await Task.Delay(TimeSpan.FromSeconds(15));    return new StatusCodeResult((int)HttpStatusCode.OK);}

I also find another SO thread, you could refernce to it.