Skip to content
StackDecode
System Design
16. Performance EngineeringAnimated

Thread Pool Management

Limiting concurrent threads.

The idea

A fixed set of workers takes tasks from a queue, avoiding thread explosion.

Watch it work

Press play, pause, or step through. Some animations have settings you can change.

arrivals 4queue 1allowed 4 rejected 0steady rate
  • allowed
  • rejected

4 arrive, 3 are served. The queue holds 1.

tick:
1
allowed:
4
rejected:
0
1/24

Bars show how many requests were let through each tick.

Step by step

  1. 1Create a pool of workers
  2. 2Queue tasks
  3. 3Workers take tasks
  4. 4Bound the queue

Where it is used

Servers and batch jobs.

Watch out for

Blocking tasks can starve the pool.

Related