Size a thread pool from the ratio of waiting to computing time.
CPU-bound work needs roughly one thread per core, while IO-bound work needs many more because threads spend most of their time waiting. The blocking coefficient is what distinguishes the two cases. Oversizing a CPU-bound pool causes context-switch thrashing, while undersizing an IO-bound pool leaves cores idle — the failure modes are opposite.
Thread Pool
Pool size = cores × target utilisation × (1 + wait time ÷ compute time)
Pool size = cores × target utilisation × (1 + wait time ÷ compute time) CPU-bound work needs roughly one thread per core, while IO-bound work needs many more because threads spend most of their time waiting. The blocking coefficient is what distinguishes the two cases.
Oversizing a CPU-bound pool causes context-switch thrashing, while undersizing an IO-bound pool leaves cores idle — the failure modes are opposite.
This calculator takes 4 inputs: CPU cores available, CPU time per task, Waiting time per task, Target CPU utilisation. The pre-filled defaults are a realistic starting point — replace them with figures from your own environment for a result you can act on.