Home > View Post

Dedicated thread or a ThreadPool thread. Or a Custom ThreadPool thread

I've just finished reading my colleague Pedram Rezaei's great post entitled Dedicated thread or a Threadpool thread? and there are some little points I'd like to add.

The post notes how the ThreadPool will only release a new thread every 500ms. Whilst there is logic to this (it stops the pool creating expensive threads for every little workitem that turns up), it does limit the ThreadPool's capability to support burst load. We discussed and analysed the effect of this in an earlier post: Tuning the ThreadPool.

The solution to this is to set the minimum threads to a larger number. However, during the course of one particular project we were still unhappy with the performance of the CLR ThreadPool and took the brave step of trying an open source alternative in this post: More fun with ThreadPools.

This graph shows the rather compelling results:

Custom ThreadPool vs CLR ThreadPool

Note how, when we're using the Custom ThreadPool there is absolutely no increase in the response time as we slowly increase the load. Not the case with the CLR ThreadPool. Just look how many extra request/sec we manage to squeeze through!

Now let's be clear here. I'm not saying you should throw out the CLR ThreadPool baby with the bathwater. But if you have a server project that makes critical use of threading you should consider trying both.

Links

Tags: .NET

 
Josh Post By Josh Twist
1:17 PM
05 Aug 2007

» Next Post: Feedback for your Smart Client
« Previous Post: Testing Constructors with the ClassTester

Comments are closed for this post.

© 2005 - 2017 Josh Twist - All Rights Reserved.