Stress Testing
In one line
Stress testing increases load beyond expected limits to find when and how the system breaks — and if it recovers.
In simple words
Stress testing answers: "What happens when we exceed our capacity?" It deliberately pushes the system beyond its design limits to find the breaking point.
What stress testing reveals:
- Breaking point — the exact load where the system fails
- Failure mode — how it fails (graceful degradation vs crash)
- Recovery — does it recover after load decreases?
- Bottlenecks — what fails first (database connections, memory, CPU)
- Error handling — are errors handled gracefully?
Process:
- Start with expected load
- Gradually increase beyond expected (2x, 5x, 10x)
- Continue until the system breaks
- Observe failure behavior and error messages
- Decrease load and check if system recovers
Common findings:
- Database connection pool exhausted
- Out of memory errors
- Thread pool saturation
- Cascading failures
- Timeout cascades
Tools: k6, JMeter, Locust, Gatling.
Example
// k6 stress test — push beyond limits
import http from 'k6/http';
import { check } from 'k6';
export const options = {
stages: [
{ duration: '1m', target: 500 }, // 5x normal load
{ duration: '2m', target: 1000 }, // 10x normal load
{ duration: '2m', target: 2000 }, // 20x normal load
{ duration: '1m', target: 5000 }, // 50x normal load — expect failure
{ duration: '3m', target: 0 }, // ramp down — check recovery
],
};
export default function () {
const res = http.get('https://api.example.com/products');
check(res, {
'status is 200': (r) => r.status === 200,
'status is 503': (r) => r.status === 503, // expected at high load
});
}
// Run: k6 run stress-test.js
// Watch for:
// - When does error rate spike?
// - What's the last successful throughput?
// - Does the system recover when load drops?Stress test ramps load to 50x normal. Watch when errors start, how the system fails (503 graceful vs crash), and whether it recovers when load drops.
Common confusions
Confused with: load testing
The difference: Load testing verifies the system handles expected traffic — tests normal conditions. Stress testing pushes beyond expected limits to find the breaking point — tests failure conditions. Load testing is about meeting requirements; stress testing is about understanding limits and failure behavior.
Related terms
Related Resources
Related Lessons
- Performance Testing
Stress testing.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.