I've been told that ASP.NET is multithreaded by default in IIS. How is this threading achieved?
Does the server farm send different requests to different cores?
Does a single request make use of multiple cores?
More importantly, are there any advantages to adding threads to ASP.NET code if the threading is done higher up in IIS?
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).
ASP.NET Threading Inside the ASP.NET Worker Process, there are two thread pools. The worker thread pool handles all incoming requests and the I/O Thread pool handles the I/O (accessing the file system, web services and databases, etc.).
The first is that every ASP.NET application (MVC or otherwise) is inherently multi-threaded: Each request will be processed on a separate thread, so you are automatically in a multi-threading situation and must consider this with any shared access to data (e.g. statics, etc.).
Thread class is used for working with threads. It allows creating and accessing individual threads in a multithreaded application. The first thread to be executed in a process is called the main thread. When a C# program starts execution, the main thread is automatically created.
Not only does the server farm different requests to different threads, but a single request can change thread during the course of life cycle. This is called thread agility. I'm looking for a good article explaining it...
EDIT: No definitive articles yet, but one blog post explaining some of the difficulties.
EDIT: More links from comments:
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