5

Just out of curiosity , What is the maximum number of threads available for handling request in asp.net.

And does asp.net releases them for any I/O or database operations so that maximum number of requests can be handled?

Kunal
  • 1,913
  • 6
  • 29
  • 45

3 Answers3

4

It is controlled via machine.config.

configuration > system.web > processModel

<processModel 
   maxWorkerThreads="num"
   maxIoThreads="num"
   minWorkerThreads="num"
   minIoThreads="num"
   ...
   />

It is set on a per CPU basis. Default for single CPU is 20/20.
http://msdn.microsoft.com/en-us/library/7w2sway1(v=VS.100).aspx

Mrchief
  • 75,126
  • 20
  • 142
  • 189
  • Thanks for that information, But i am still confused on the second part of my question that whether the worked thread is released if asp.net code is busy doing some IO or database operation. – Kunal Jul 11 '11 at 20:48
  • 1
    `ThreadPool` is managed by the framework. As such, its hard to predict when it'll be released. But then, the whole idea is that you shouldn't have to bother with it. – Mrchief Jul 11 '11 at 20:57
3

To release worker threads for I/O operations, you'll want to use the async/await pattern. When you "await" an async file operation, the thread will be released back to the ASP.NET thread pool, which is then used to process other requests until your file i/o operation is completed.

http://www.asp.net/mvc/tutorials/mvc-4/using-asynchronous-methods-in-aspnet-mvc-4

Tim P.
  • 2,903
  • 24
  • 26
3

In .net 4.0 has it is 250 worker threads per CPU and 1,000 I/O completion threads...

Manoj Talreja
  • 793
  • 3
  • 11
  • 18