Threadpool

Here is a .Net Threadpool performance tip. Prior to .Net 2.0 service pack 1, the default thread count in the Threadpool was 25 worker threads and 1000 IO threads per processor. In service pack 1, Microsoft increased the default thread count to 250 worker threads. Most people know that when you use the Threadpool object in your application to manage background threads and you run out of threads, it can have a negative impact on the performance of your application. But did you know that if you don't have enough idle threads it can be a performance bottleneck as well? This is especially true in systems that often experience spikes in requests for additional threads.

The default number of idle threads is 1 thread per processor. And there is a delay of half a second in creating a new thread. So if there is a burst of activity in your system and more threads are needed in the Threadpool, the slow down could get progressively worse. This problem could be alleviated by simply calling

ThreadPool.SetMinThreads(50,100)

to increase the number of idle threads. The max thread count and min thread count values should be configurable since the settings would have to be fine tuned depending on the hosting hardware.
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati
posted @ Sunday, February 08, 2009 12:57 AM
Print

Comments on this entry:

No comments posted yet.

Your comment:



(not displayed)


 
 
 
 
 

Live Comment Preview:

 
«February»
SunMonTueWedThuFriSat
2930311234
567891011
12131415161718
19202122232425
26272829123
45678910