What is chaos testing?
Chaos testing (chaos engineering) is the discipline of injecting controlled failures into a system to discover weaknesses before real outages do. Popularised by Netflix's Chaos Monkey, the practice matters doubly for APIs: they sit in the middle of dependency chains, so one slow downstream call can cascade into a full outage — timeouts pile up, thread pools exhaust, retries amplify the load.
Why functional tests aren't enough
Your functional suite proves the API works when everything around it works. Production never grants that assumption. The database gets slow. The payment provider times out. A partner hammers you at 10× the agreed rate. Chaos testing asks the only question that matters during an incident: what does the system do next? Fail fast with a clear error? Serve stale cache? Or hang, exhaust connections and take neighbours down with it?
The five core chaos scenarios for APIs
| Scenario | What's injected | What it exposes |
|---|---|---|
| Latency injection | +500ms–5s on responses or dependencies | Missing timeouts, UI hangs, retry storms |
| Service failure | A dependency returns 5xx or drops | Absent fallbacks, cascade paths, poor error messages |
| Timeout scenarios | Connections that never complete | Connection-pool exhaustion, hung workers |
| Rate limiting | 429s and throttling from dependencies | Backoff bugs, retry amplification |
| Resource pressure | Bursts alongside constrained resources | Memory leaks, queue overflow, GC spirals |
How to run a chaos experiment (the method)
- Define steady state. Pick measurable normals: p95 latency, error rate, throughput.
- Form a hypothesis. "If the search dependency times out, checkout still completes within 2s using cached results."
- Limit the blast radius. Start in staging, one endpoint, one failure type. Chaos in production is a graduation, not a starting point.
- Inject exactly one failure. Multiple simultaneous variables teach nothing.
- Compare against steady state. Did the system degrade gracefully or surprisingly?
- Fix, document, repeat harder. Every surprise is a production incident you cancelled in advance.
What "graceful degradation" looks like
- Timeouts are explicit and short; nothing waits forever.
- Failures return fast, structured errors — not hangs or stack traces.
- Retries use exponential backoff with jitter and a budget.
- Circuit breakers isolate sick dependencies.
- The core user journey survives non-core failures.
Chaos testing with Flasqo
Flasqo's chaos module simulates latency injection, service failures, timeout scenarios and rate limiting against your API without infrastructure changes — configure the scenario, run it, and read the resilience report alongside your load tests and functional suites. It's free: run your first chaos experiment.