Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do ASP.NET worker threads spend most of their active time in a blocked state?

Tags:

c#

asp.net

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?)?

like image 694
Mr. Smith Avatar asked Apr 16 '13 18:04

Mr. Smith


People also ask

Why is my ASP.NET site so slow?

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.

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.

Is ASP NET core single threaded?

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).


1 Answers

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.

like image 125
Nate Dudek Avatar answered Sep 29 '22 17:09

Nate Dudek