Geeks With Blogs
HanSolo code monkey
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. Posted on Sunday, February 8, 2009 12:57 AM | Back to top


Comments on this post: Threadpool

No comments posted yet.
Your comment:
 (will show your gravatar)


Copyright © HanSolo | Powered by: GeeksWithBlogs.net