I'm trying to determine the role of ASP.NET worker threads. My IIS 7 installation defaulted to allowing a maximum of 25 worker threads, whereas I would have otherwise set it to 1.
When a user requests an .aspx
page, I understand that that request will retrieve a worker thread. But does the loading of each of the images on that page also grab a worker thread? And once an image is retrieved, is the worker thread that retrieved it also responsible for transmitting it to the user (via blocking-tcp-sockets?)?
An IIS or ASP.NET hang can cause your website to have slow page loads, timeouts, or 503 Service Unavailable errors. Hangs can be caused by blocked ASP.NET threads, bad configuration, or request queueing.
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.
In short, ASP.NET is multithreaded and when processing a particular request, may even switch to another thread at particular steps during the request life cycle (and it could be worse with async pages).
Let's walk through how a web request to an ASPX page looks to a user and their browser.
The user navigates their browser to the ASPX page. On the server, IIS recognizes this as an ASP.NET request and routes it to the .NET handlers for processing, which includes taking a worker thread, processing the page, and delivering the resulting HTML back to the user's browser. This does not include delivering the actual images, JavaScript files, CSS files, and other external resources - just the resulting HTML from the page itself goes back to the user's browser.
When the user's browser renders the page, it will then make additional requests for the other resources on the page - images, JavaScript files, etc. When IIS receives the requests for these files, it will process them as static content, and therefore the ASP.NET handlers (and their worker processes) is not involved in processing or delivering the content.
Note that you can configure IIS to use the .NET handlers to process these types of requests, but for static content, IIS won't do that out-of-the-box.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With