Skip to content

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:

  1. Breaking point — the exact load where the system fails
  2. Failure mode — how it fails (graceful degradation vs crash)
  3. Recovery — does it recover after load decreases?
  4. Bottlenecks — what fails first (database connections, memory, CPU)
  5. Error handling — are errors handled gracefully?

Process:

  1. Start with expected load
  2. Gradually increase beyond expected (2x, 5x, 10x)
  3. Continue until the system breaks
  4. Observe failure behavior and error messages
  5. 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

javascript
// 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

Decode error messages

Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.

View errors

← Back to glossary