What you'll learn: By the end of this lesson you will be able to write a chaos experiment as a hypothesis about steady state, choose which fault to inject (latency, errors, dropped responses), limit the blast radius with a cap and a stop condition, read the result as a finding rather than a pass or fail, and explain what an in-process model can and cannot show.
A fire drill does not start a fire. It tests, at a chosen hour with the fire marshal watching, whether people find the exit, whether the doors open and whether the alarm is audible. The building passes or fails in a way that costs ten minutes, not lives. Nobody runs a drill by locking all the exits at once, and everyone knows who can call it off.
Chaos engineering is the same idea for software: deliberately cause a failure in a controlled experiment, to find out whether the failure handling you designed works, before a real outage finds out for you. It does not replace the designs it tests. Timeouts, retries, fallbacks and breakers and bulkheads are the mechanisms; failure handling end to end shows how they fit together; chaos experiments are how you learn whether they work. The planned lessons on circuit breakers and bulkheads and on Resilience4j in Spring cover two of those mechanisms in depth and are not linked yet.
Verified against principlesofchaos.org, the AWS Fault Injection Service documentation, the Netflix Tech Blog and the Google SRE book on 2026-12-01. The lab is an in-process model: it injects faults into a fake dependency, not into real infrastructure, and no real chaos experiment is described here.
The core idea
A chaos experiment is a falsifiable claim: "while this fault is in place, this measurable thing stays within these limits." You run it to try to prove the claim wrong. If it holds, you gain evidence. If it breaks, you found a weakness cheaply, with the fault under your control.
Three examples run through the lesson, each labelled:
- Minimal example: one fault, one client, one claim: "if 30% of pricing calls are 400 ms slower, shoppers still get a page in 250 ms".
- Realistic example: ShopStream's product page and its Pricing dependency, in "In practice".
- Failure example: a dropped response, where the work happened but the caller never heard, so a retry does it twice.
The loop: steady state, hypothesis, fault, compare
The Principles of Chaos Engineering describe an experiment in four steps: define steady state as a measurable output that shows normal behaviour; hypothesise that it will hold in both a control group and an experimental group; introduce variables that mirror real-world events, such as crashed servers or severed network connections; and try to disprove the hypothesis by looking for a difference in steady state between the two groups.
The page stresses that steady state is the measurable output of a system, "rather than internal attributes of the system", and names throughput, error rates and latency percentiles as proxies. That is the useful discipline: you write the hypothesis in terms a user would notice. AWS's guidance on planning experiments gives the sentence template: "If {fault injection action} is performed, the {business or technical metric impact} should not exceed {value}."
(a measurable output)"] --> H["Write the hypothesis
If fault, then metric stays within limit"] H --> C["Run the control
no fault"] C --> I["Inject the fault
small blast radius, stop condition armed"] I --> D{"Steady state
differs from control?"} D -->|no| R["Hypothesis held:
evidence, widen scope later"] D -->|yes| F["Weakness found:
fix it, run again"]
Figure 1. The experiment loop. How to read this: the control run comes before the fault, because "different from normal" needs a normal to compare with. A breach is the useful outcome: it is a weakness found while the fault was small and switched on by you.
What to inject: latency, errors, dropped responses
The Principles say variables should reflect real events, prioritised by potential impact or estimated frequency. For a service that calls other services over a network, three faults cover most of the ground, and they behave differently.
| Fault | What the caller sees | Did the dependency do the work? | What it tests |
|---|---|---|---|
| Latency | An answer, later than usual | Yes | Timeouts, thread and connection limits, tail latency |
| Error | A fast failure | No | Retries, fallbacks, error handling |
| Dropped response | Silence, then a timeout | Yes | Timeouts, and whether repeating the call is safe |
Netflix described tools of this kind in its Simian Army article. Chaos Monkey "randomly disables our production instances" to confirm the system survives common failures without customer impact, and the article says it runs during business hours with engineers monitoring. Latency Monkey "induces artificial delays" in the client-server communication layer, and very large delays can simulate a node or whole service being down without taking it offline.
The third row is the one teams forget. When a response is lost, the caller cannot tell "never ran" from "ran and the answer vanished".
Figure 2. The failure example. How to read this: from the client's side attempt 1 failed. From the dependency's side it succeeded. Retrying is only safe if the work is idempotent (see idempotent and commutative operations and delivery guarantees); the experiment's job is to show whether yours is.
Blast radius and stop conditions
The Principles give blast radius its own rule: some short-term negative impact is accepted, but the chaos engineer has the responsibility to ensure the fallout is minimised and contained. Two mechanisms do that work.
A cap on the blast radius limits what the experiment can touch: one instance, a small share of calls, a short duration. AWS describes an experiment template as holding actions, targets and stop conditions; a target can be specific resources or a group chosen by tags or state, and each action runs for a specified duration or until you stop the experiment. Its planning guidance says to start with small, simple experiments, such as stopping one instance. The Google SRE book's canary footnote has a similar rule of thumb: start by affecting 0.1% of user traffic and scale up by orders of magnitude.
A stop condition is the abort switch. AWS defines it as a mechanism that stops an experiment when a threshold you define as a CloudWatch alarm is reached; a stopped experiment cannot be resumed, and the alarm comes from the steady state you defined first. The idea is not tied to that product: any experiment needs an automatic "this is hurting users, stop" that does not wait for a person to notice.
Figure 3. The life of one experiment. How to read this: two exits lead out of "Injecting", and both switch the fault off. An experiment whose only exit is "someone remembers to turn it off" has no blast-radius control.
Where to run it, and what a model cannot tell you
The Principles favour running experiments in production, because real traffic is the most reliable way to capture actual request paths, and favour automating them. AWS's documentation is more cautious about starting points: its service acts on real resources, so it recommends a planning phase and a pre-production test first, and good monitoring and alerting beforehand, since without them you cannot measure the impact. Both fit one path: start small and safe, with strong observability, and widen as the evidence builds.
The lab below sits at the very start of that path. It is a model: it shows how the pieces of an experiment fit together and what each fault does to a client, with modelled time. It cannot tell you how a real network, thread pool or database behaves under the same fault. The Google SRE book notes that random techniques of this family "aren't necessarily repeatable tests" and suggests logging the random seed to replay a run, which is why the lab fixes its seed.
Build it
The lab is examples/spring-labs/labs/chaos-fault-injection (plain Java; the Spring Boot build supplies only the JUnit and AssertJ versions; no Docker, no network, no real infrastructure). It models the ShopStream product page calling a Pricing dependency.
Figure 4. The harness. How to read this: the runner sends requests to the client; every call to the dependency passes through the injector, which affects a seeded share of them. The steady-state check reads the answers and, when a window breaches the hypothesis, tells the injector to stop.
The injector decides, for each call, whether to inject. A cap and a stop switch sit in front of a seeded random draw:
private boolean shouldInject() {
if (stopped || fault.kind() == Kind.NONE || injected >= maxInjections) {
return false;
}
return random.nextInt(100) < fault.percent();
}
The runner checks the hypothesis on every window of 20 requests and trips the stop switch on the first breach:
if (window.size() == WINDOW) {
if (stopOnBreach && abortedAt == 0 && !HYPOTHESIS.holds(window)) {
injector.stop();
abortedAt = i + 1;
}
window.clear();
}
The hypothesis is the lab's own and illustrative: at least 99% of requests answered and a 95th-percentile wait of at most 250 ms. The healthy dependency answers in 20 ms. Three clients are compared: naive (timeout 1000 ms, no retry, no fallback), guarded (timeout 100 ms, one retry, a stale-copy fallback) and retrying (timeout 100 ms, two retries, no fallback). Each experiment sends 200 requests; the fault decisions use a fixed seed. "injected" counts affected calls to the dependency, so a retry can add to it.
Expected output, captured from a real run (nine experiments, 200 requests each, modelled time):
Steady-state hypothesis: at least 99% of requests answered and p95 wait at most 250 ms.
200 requests per experiment, stop-condition window 20 requests, modelled time (nothing sleeps).
experiment injected answered fallback p95 ms dep calls hypothesis aborted at
1 control, no fault, guarded 0 100% 0 20 200 holds -
2 latency +400 ms on 30%, naive 62 100% 0 420 200 BREACHED -
3 latency +400 ms on 30%, guarded 75 100% 14 201 261 holds -
4 errors on 50%, naive 109 45% 0 20 91 BREACHED -
5 errors on 50%, guarded 158 100% 45 25 155 holds -
6 dropped responses on 30%, retrying 80 98% 0 220 276 BREACHED -
7 errors on 100%, naive, no limit 200 0% 0 5 0 BREACHED -
8 errors on 100%, naive, cap 10 10 95% 0 20 190 BREACHED -
9 errors on 100%, naive, stop condition 20 90% 0 20 180 BREACHED request 20
How to read it:
- Row 1 is the control. With no fault the guarded client answers everything with a p95 of 20 ms. Every other row is compared with it.
- Rows 2 and 3 are the same latency fault. The naive client waits for every slow call: everyone is answered but the p95 is 420 ms, so the hypothesis breaks on latency alone. The guarded client gives up at 100 ms and retries or falls back; its p95 is 201 ms (two 100 ms timeouts plus the 1 ms cache read) and it holds.
- Rows 4 and 5 are the same error fault. The naive client passes the errors on (45% answered). The guarded client retries, falls back 45 times and holds, at the price of 155 dependency calls for 200 requests: retries are extra load.
- Row 6 is the dropped response. The dependency ran 276 times for 200 requests: for 76 of them the work ran again after a reply was lost. If that work were "reserve one item", 76 items would be reserved twice.
- Rows 7 to 9 are blast radius. With no limit, an error on every call takes every answer away (row 7). A cap of 10 injections limits the damage to 5% of requests (row 8). The stop condition notices the breach in the first window of 20 and switches the fault off, and the other 180 requests are normal (row 9). All three say BREACHED because the naive client has no protection; the limits decide what that finding cost.
The tests (./gradlew :labs:chaos-fault-injection:test from examples/spring-labs) assert each claim and compare the table with golden/chaos-fault-injection.txt.
Trade-offs
| Choice | Gain | Cost | Wrong when |
|---|---|---|---|
| Run in a test environment first | No customer risk, safe to learn on | The environment differs from production | It is the only place you ever test |
| Run in production | Real traffic and real configuration | Real users can be affected | You have no stop condition or observability |
| Small blast radius | Contained damage | Weaker signal; rare faults may not show | You never widen it |
| Automate and repeat | Catches regressions and drift | Tooling and upkeep | A failing experiment has no owner |
| Random faults | Finds surprises | Hard to repeat | You do not record the seed |
| Planned faults (a game day) | Repeatable, teaches people | Tests only what you thought of | It becomes a ritual with no new scenarios |
In practice: the product page and Pricing
This is a realistic scenario, not a case history.
This is an educational scenario on ShopStream, the course's grocery marketplace; nothing in it describes a real company. The shared figure is about 2,300 browsing requests per second at peak; every other number is illustrative.
The situation
The product page calls Pricing for the current price. The team wrote a fallback that serves a cached price, labelled with its age, when Pricing fails (see graceful degradation). Nobody has seen it run. The Stage 9 resilience plan in ShopStream Stage 9 promises the page survives a Pricing failure. The team must find out whether that is true before an outage does.
Starting architecture
Figure 5. The path under test. How to read this: the red dashed edge is the fallback nobody has exercised. The experiment is about that edge and the 1 s timeout in front of it.
Options considered
| Option | What it proves | Cost | Risk |
|---|---|---|---|
| A. Read the code and trust it | Nothing about behaviour | None | The first real test is an outage |
| B. A test-environment experiment: Pricing +400 ms on 30% of calls, then errors on 50% | Whether timeout and fallback behave as designed | A staging copy and a day of work | Staging may differ from production |
| C. Start in production at full scale | Real behaviour | None to set up | Large blast radius, no learning ladder |
The decision
Option B, with a written hypothesis (the numbers are illustrative): "If Pricing responds 400 ms slower for 30% of calls, at least 99% of page requests are answered and the page's p95 stays within 250 ms." A second, separate hypothesis covers 50% errors. Blast radius: the staging environment, one Pricing instance, ten minutes, with a stop condition that switches the injection off when the answered share drops below the limit. The control run comes first. Success is not "it passed": a breach is expected to teach something.
Rollout and verification
Run the control, then the latency fault, then the error fault, each with the stop condition armed. The evidence is the answered share, the p95, the share of responses served from the fallback and the number of Pricing calls per page. Based on the lab's pattern, the first run probably breaches on latency, because a 1 s timeout lets every slow call finish; the fix is a shorter timeout and a retry budget. Repeat until the hypothesis holds, then repeat on a schedule so a later change cannot silently remove the protection. Widen the scope (a canary in production, a small share of traffic) only after staging holds.
The 2 a.m. failure
Weeks later the team runs the error experiment against a production canary. The experiment job crashes after turning the fault on, and nothing turns it off: Pricing errors continue past the planned ten minutes. At 02:10 the alert fires: "product page fallback share above 40 percent". The cause is in the harness, not in Pricing: the injection had no expiry, so it ran until someone noticed. First checks: the injection flag and its start time, which experiment owns it, and the fallback share. Mitigation: switch the flag off. Follow-up fixes: every injection carries a duration and expires by itself (AWS actions likewise run for a specified duration), the stop condition is tested by deliberately crashing the experiment job, and each experiment has a named owner.
Architect's notes
- Write the hypothesis before the fault, in numbers a user would notice. "Answered share and p95", not "CPU stays low".
- Always run a control. Without it, a bad result might just be a bad day.
- Arm the stop condition and test it. An abort that has never run is a fallback you never ran.
- Give every fault a duration. Self-expiring injection is the cheapest blast-radius control.
- Count side effects, not only answers. A client can look healthy while the dependency did the work twice.
- Treat a breach as a finding with an owner. Record it, fix it, rerun it.
Common mistakes
- No hypothesis. "Let's kill something and see" teaches little and cannot be repeated.
- Starting in production at full scale. Climb the ladder: model, test environment, small canary.
- Injecting without observability. If you cannot see the steady-state metric, you cannot run the experiment.
- A stop condition on a metric the fault does not move. It never trips.
- Forgetting dropped responses. The lost reply and its duplicate work go untested.
- A one-off game day. The system changes; the experiment needs to run again.
Key takeaways
- A chaos experiment is a falsifiable claim about steady state, tested against a control.
- Inject latency, errors and dropped responses: they exercise different defences.
- A dropped response means the work may have run; retries need idempotent operations.
- Limit the blast radius with a cap and a duration, and arm a tested stop condition.
- A breach is the useful outcome; fix it and rerun on a schedule.
- A model shows how the parts fit; only real systems, run carefully, show how they behave.
Practice exercises
Exercise 1 (30 min). Write a hypothesis for your own service's most important dependency in the template "If (fault), the (metric) should not exceed (value)", and name the control.
Exercise 2 (45 min). In the lab, change the guarded timeout to 300 ms and predict the p95 of experiment 3 before you run it. Explain the result.
Exercise 3 (1 hour). Make the injector decide per request so a retry meets the same fault. Which of experiments 3 and 5 change, and what does that say about independent-failure assumptions?
Exercise 4 (45 min). Design the stop condition and the expiry for a production canary experiment on your own system. What do you check to prove the abort works?
Related reading
- Failure Handling End to End: the mechanisms an experiment tests.
- Graceful Degradation and Fallbacks: the fallback in the ShopStream scenario.
- Timeouts, Retries, Exponential Backoff and Jitter: the timeout and retry settings the lab varies.
- Load Shedding and Retry Storms: what retries add when a dependency is struggling.
- Resilience Patterns: breakers and bulkheads.
- Runbooks, Incidents and Postmortems: game days and what to do with the findings.
- Observability and SLOs: the steady-state metrics an experiment depends on.
Official documentation
- Principles of Chaos Engineering: the definition, the experiment steps and the advanced principles.
- AWS Fault Injection Service: What is AWS FIS?: experiment templates, actions, targets and stop conditions.
- AWS Fault Injection Service: Planning your experiments: hypothesis format and starting small.
- AWS Fault Injection Service: Stop conditions.
- Netflix Tech Blog: The Netflix Simian Army: Chaos Monkey and Latency Monkey.
- Google SRE book: Testing for Reliability: random fault techniques, seeds and canaries.