๐ Bottleneck Hunting ยท Days 19โ24
Day 21: Thread / CPU Saturation
Objective
Push CPU toward 100% and observe system behavior beyond saturation.
Scenario
Ramp load until CPU hits ~90-95%. Hold it there for a few minutes. Watch what happens to throughput and response time as you try to add even more load.
Metrics to Watch
When It Clicks
Past saturation, more load only makes everything slower.
Solution
Run a step-load test (every 5 min add 10 users) while watching `top` or a Prometheus CPU dashboard. When CPU crosses ~90%, note the user count. Keep adding users: throughput will plateau then fall as the OS spends more time on context switching than actual work. The run queue (`vmstat` column 'r' on Linux) exceeding logical CPU count is the technical definition of saturation. This user count minus 10-20% is your safe operating ceiling for a CPU-bound workload.
Reflection
At what CPU threshold did adding more users make things worse, not better?
Deliverable
A saturation-finding script with CPU correlation notes.
โ ๏ธ Never run load tests against infrastructure you do not own or have explicit written permission to test. Always use a dedicated test environment. Unauthorized load injection can cause outages, trigger legal liability, and violate terms of service.