← Lessons

quiz vs the machine

Gold1360

Concurrency

The CPU Bound vs IO Bound

Why a task's bottleneck decides whether more threads or async wins.

4 min read · core · beat Gold to climb

Where the time goes

A workload is CPU bound when its speed is limited by how fast the processor can compute, and IO bound when it spends most of its time waiting on input and output such as disk, network, or a database.

Matching the model to the bottleneck

The bottleneck decides the right concurrency tool:

  • CPU bound work needs real parallelism across cores. Adding more threads than cores does not help, since the cores are already busy; it only adds switch overhead.
  • IO bound work spends time waiting, so a single core can juggle many tasks while each waits. Async or many lightweight tasks shine here, because waiting tasks cost almost nothing.

A common mistake

Throwing thousands of threads at a CPU bound job wastes memory and adds context switches without speeding anything up. Conversely, using only as many threads as cores for an IO bound job leaves the CPU idle while threads sit blocked on the network. Knowing which kind you have guides whether to parallelize or to overlap waiting.

Key idea

CPU bound work needs parallelism up to the core count while IO bound work benefits from overlapping many waiting tasks, so identifying the bottleneck guides the concurrency choice.

Check yourself

Answer to earn rating on the learn ladder.

1. What does an IO bound workload spend most of its time doing?

2. Why does adding far more threads than cores not speed up CPU bound work?