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.
- 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
- 1Create a pool of workers
- 2Queue tasks
- 3Workers take tasks
- 4Bound the queue
Where it is used
Servers and batch jobs.
Watch out for
Blocking tasks can starve the pool.