HomeGuides › API chaos testing

API chaos testing: fault injection and resilience

By the Flasqo team · Updated 24 August 2026

In short

Chaos testing injects deliberate failure — latency, dropped connections, forced 5xx, rate limits — to verify a system degrades gracefully. Every experiment starts from a written hypothesis and a defined blast radius.

  • Chaos testing injects deliberate failure — latency, dropped connections, 5xx responses, rate-limit rejections — to verify a system degrades gracefully instead of collapsing.
  • It answers a different question from load testing: load asks whether you survive volume, chaos asks whether you survive faults.
  • Every experiment should start from a written hypothesis. Without one you generate noise rather than evidence.
  • Most of the value is available in staging, at a fraction of the risk of production experiments.

What is chaos testing?

Chaos testing — often called chaos engineering — deliberately introduces faults into a running system to observe how it responds. The premise is straightforward: these conditions will occur in production eventually, so it is better to trigger them on a Tuesday afternoon with the team watching than at 3am with nobody sure what changed.

For APIs specifically, it means intercepting calls to dependencies and making them behave badly: adding two seconds of latency, returning a 503, closing the connection mid-response, or rejecting with a 429. Then you check whether the timeouts, retries and circuit breakers you wrote actually do what you believe they do.

Almost every team has resilience code. Very few have evidence it works. A retry policy that has never been exercised is a hypothesis, not a safeguard — and a surprising proportion of them make outages worse by amplifying load against an already-struggling dependency.

Chaos testing vs load testing

These are frequently confused, and they find entirely different defects. A service can sustain ten thousand requests per second and still fall over completely when one downstream dependency starts responding in 30 seconds instead of 30 milliseconds — because every worker thread ends up blocked waiting on it.

Load testingChaos testing
QuestionDoes it survive volume?Does it survive faults?
VariableTraffic rateDependency behaviour
Typical findingSaturation point, slow queriesMissing timeouts, retry storms, cascading failure
VerifiesCapacityCircuit breakers, fallbacks, graceful degradation

The fault types worth injecting

Latency injection

Add delay to a dependency's responses. This is the highest-value single experiment, because latency is the failure mode most systems handle worst. A dependency that is slow rather than down keeps connections occupied, and without an aggressive timeout the calling service exhausts its own thread or connection pool — turning one slow dependency into a total outage.

Error injection

Return 500 or 503 from a dependency at a controlled rate. Verify the caller distinguishes retryable from non-retryable failures, applies exponential backoff with jitter, and gives up rather than retrying indefinitely.

Connection failure

Refuse connections or close them mid-response. Truncated responses are especially revealing: code that parses a partial JSON body often throws an unhandled exception rather than treating it as a failed call.

Rate-limit simulation

Return 429 with a Retry-After header. Confirm the client honours the header rather than immediately retrying — a client that ignores Retry-After under load will keep a rate-limited dependency permanently saturated.

Running an experiment properly

  1. State the hypothesis in writing. "If the payments service adds two seconds of latency, checkout still completes because the circuit breaker opens after five consecutive failures and we fall back to the queued path." A hypothesis you can be wrong about is the entire point.
  2. Define the blast radius. Which service, which percentage of traffic, which environment. Start small enough that being wrong is cheap.
  3. Define the abort condition. The specific metric and threshold at which you stop — and confirm you can stop in a single action before you start.
  4. Measure the steady state first. You cannot detect degradation without a baseline taken minutes earlier, not last quarter.
  5. Inject the fault and observe. Watch the caller, not just the faulted dependency. Cascading failure is the finding that matters.
  6. Write down what actually happened. A disproved hypothesis is the most valuable outcome — it is a real defect found without an incident.

What chaos testing typically uncovers

Is it safe to run in production?

With discipline, yes — that is where the highest-fidelity signal lives, since staging never quite matches production's data volume, traffic mix or infrastructure. But the sequence matters: prove the experiment in staging first, scope it to a small percentage of traffic, run it during business hours with the team available, and make sure a single action stops it.

For most teams the honest answer is that staging experiments deliver the majority of the value at a small fraction of the risk. Production chaos is worth graduating to, not starting with.

Test your API without writing the tests

Paste a URL. Flasqo discovers your endpoints, generates the suite and runs it — free, no credit card.

Start testing free

Frequently asked questions

What is chaos testing for APIs?

Chaos testing deliberately injects failure — latency, dropped connections, 5xx responses, rate-limit rejections — into a running system to verify it degrades gracefully. The premise is that these conditions will occur in production anyway, so it is better to trigger them on a Tuesday afternoon than at 3am.

How is chaos testing different from load testing?

Load testing asks whether the system survives volume. Chaos testing asks whether it survives faults. A service can handle ten thousand requests per second and still fall over completely when one downstream dependency starts responding in 30 seconds instead of 30 milliseconds.

What should a chaos experiment prove?

A good experiment starts from a written hypothesis such as "if the payments service adds two seconds of latency, checkout still completes because the circuit breaker opens after five failures". You then inject exactly that fault and check the hypothesis. An experiment with no prior hypothesis produces noise rather than evidence.

Is it safe to run chaos tests in production?

Only with a controlled blast radius, a defined abort condition and someone watching. Start in staging, keep the fault scoped to a small percentage of traffic, and make sure you can stop the experiment in one action. Most of the value is available in staging for a fraction of the risk.

Related reading

API Testing: The Complete Guide API Smoke Testing: Fast Health Checks for Critical Endpoints API Regression Testing: Prevent Breaking Changes in Production API Fuzz Testing: Break It Before Attackers Do API Integration Testing: Validate Multi-Endpoint Workflows API Auto-Discovery: Endpoint Detection & Scoring Vibe Testing: AI-Powered Test Generation From Real Artifacts Flasqo vs k6 Flasqo vs Apidog 11 Best Free API Testing Tools in 2026 9 Best Postman Alternatives in 2026