Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the maximum number of threads in Windows Server 2003?

Does anyone know? And a bigger question is what happens when you encounter this maximum? Is this the same number with other Windows OSs such as Vista, XP etc.?

like image 965
Douglas Anderson Avatar asked Jan 27 '09 00:01

Douglas Anderson


People also ask

How many threads can windows server handle?

Each core can only run 1 thread at a time, i.e. hyperthreading is disabled. So, you can have a total maximum of 20 threads executing in parallel, one thread per CPU/core.

Is there a limit to number of threads?

The maximum threads setting specifies the maximum number of simultaneous transactions that the Web Server can handle. The default value is greater of 128 or the number of processors in the system. Changes to this value can be used to throttle the server, minimizing latencies for the transactions that are performed.

How many maximum threads can you run in the 32 bit machine?

The number of threads with the default stack size is approximately 2000 threads on a 32-bit system and 8000 billion on a 64-bit system.

What is the maximum number of running threads per application instance?

The number of running threads per application instance is limited to 10 420. Reaching this limit can cause performance issues.


2 Answers

First I would advise reading this: http://blogs.msdn.com/oldnewthing/archive/2007/03/01/1775759.aspx

then http://blogs.msdn.com/oldnewthing/archive/2005/07/29/444912.aspx

To summarise, the limitation is normally stack space (which must be in contiguous blocks) and since every thread consumes this scattered about you rapidly run out of contiguous blocks. On 64 bit machines and operating systems this is much less of a problem.

Mitigation strategies exist but will only go so far (and rely on you not using much stack per thread)

As a rough guide:

  • creating tens is almost certain to work
  • hundreds is probable on current server and desktop hardware but risky
  • thousands will almost certainly fail.

You likely shouldn't need to create more than ten anyway (and if you really do need to you should know this information already)

like image 139
ShuggyCoUk Avatar answered Sep 28 '22 09:09

ShuggyCoUk


The best answer I've heard when asking such questions is:

It doesn't matter, and if you find that it does matter, you need to rethink what you're doing so that it doesn't matter.

like image 43
Rex M Avatar answered Sep 28 '22 10:09

Rex M