I have an ASP.NET 4.6 application developed as a web API. It has one long operation, which takes about 60 seconds, but this operation is not heavily loaded, even if the image is similar to Thread.Sleep(60000).
At the moment, this operation cannot be asynchronous, because it depends on a third-party non-asynchronous library, so it blocks the thread that performs this operation for 60 seconds. The problem occurs when more than 50 requests are sent to the application, new requests are waiting in the queue (sometimes up to 400). I tried to increase the minimum and maximum number of thread stream threads, like this:
ThreadPool.SetMinThreads(300, 300);
ThreadPool.SetMaxThreads(500, 500);
These values have been successfully changed, and if I run the application in IIS Express, the changes are applied and new threads are distributed very quickly (about 3 seconds), all requests are processed, everyone is happy:

However, if I run the application on IIS 10, it just allocates 40-60 threads, and the rest of the requests are queued:

How can I use ThreadPool.SetMinThreadsIIS in hosted applications correctly?
Are there other ways to achieve the same?
source
share