What's the cost of using hundreds of threads?

Nick Coghlan ncoghlan at iinet.net.au
Wed Mar 2 12:59:17 CET 2005

Steve Holden wrote:
> Apache, for example, can easily spawn more threads under Windows, and 
> I've written code that uses 200 threads with excellent performance. 
> Things seem to slow down around the 2,000 mark for some reason I'm not 
> familiar with.

As far as I know, the default Windows thread stack size is 2 MB. Do the math :)

On NT4, beyond a couple of hundred threads a *heck* of a lot of time ends up 
being spent in the kernel doing context switches (and you can kiss even vaguely 
deterministic response times good-bye).

Using a more recent version of Windows improves matters significantly.


Nick Coghlan   |   ncoghlan at email.com   |   Brisbane, Australia

More information about the Python-list mailing list