Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the benefit of having multiple thread pools versus a single one?

Under what conditions is it considered best practice to have multiple thread pools versus a single one?

I'm developing on Windows using the Microsoft threadpool for processing work items where the documentation states:

Each process can create multiple isolated pools with different characteristics as necessary. 
There is also a default pool for each process.

At initial consideration it seems like having one thread pool for the process is the preferable option so that threads are not being spun up unnecessarily when there might be existing unused threads available in other thread pools.

Obviously one exception is that noted in the documentation - when different characteristics are needed for the thread pools. What other conditions should I be considering when determining whether or not I should be using multiple thread pools versus the single default pool?

like image 341
dlanod Avatar asked Sep 07 '25 15:09

dlanod


1 Answers

All of this assumes that all threads need the same characteristics:

Normally, a single pool is best.

Sometimes, you architecturally want different components of the app to not know of each other. In that case they should not know of the thread pool of each other. So that would be an architectural decision.

In particular, if you load 3rd party components it will be hard to share pools.

One more reason would be to isolate some workload from another one if one of them is at risk of flooding the pool and interrupting the other workload.

like image 175
usr Avatar answered Sep 10 '25 05:09

usr