Chaos engineering experiment simulator
A chaos experiment breaks one thing on purpose, for a small slice of real traffic, and checks whether users notice. Pick a dependency and a fault, set the blast radius, and compare the experiment group with a control group. Then change the timeouts, retries and fallback until the steady state holds.
| Dependency | Median ms | p99 ms | Timeout ms | Retries | If it fails |
|---|---|---|---|---|---|
| Auth | page fails | ||||
| Catalog | page fails | ||||
| Recommendations (fault) |
Stopped early. The experiment group fell more than 2 points below control after 100 of its requests, so the fault was switched off.
| Experiment | Control | |
|---|---|---|
| Requests | 100 | 116 |
| Succeeded | 43.00% | 100.00% |
| p50 latency | 1,000 ms | 132 ms |
| p99 latency | 1,000 ms | 352 ms |
| Fallbacks served | 0 | 0 |
| Recommendations calls per request | 1.46 | 1.00 |
- Requests hurt by the experiment
- 57
- over the front-end deadline57
How to use the simulator
The service is a web page whose front end calls an auth service, then a catalog and a recommendations service in parallel, and must answer within its deadline. Choose which dependency to break and how: latency adds a delay to every call, errors makes a share of calls fail, and a black hole accepts calls and never answers. The blast radius is the share of requests that get the fault; the same share again forms the control group.
Each change re-runs the experiment over the given number of requests, with latencies drawn from each dependency's median and p99. The chart compares the success rate of the two groups as the run goes on, and the panel on the right says whether the steady state held. Edit timeouts, retries and the recommendations fallback in the table to fix what the experiment finds.
What is chaos engineering?
Chaos engineering is the practice of experimenting on a system by injecting the failures it will meet in production, such as slow or failing dependencies, lost servers and network trouble, to build confidence that it keeps serving users. It grew out of Netflix's move to the cloud, where any instance could disappear; their Chaos Monkey terminated instances at random so that every service had to tolerate it.
The Principles of Chaos Engineering describe the method in four steps: define the steady state as a measurable output of the system that shows normal behaviour; hypothesise that it will continue in both a control group and an experimental group; introduce variables that reflect real-world events; and look for a difference between the two groups. Disproving the hypothesis means a weakness has been found. Netflix engineers described the approach in IEEE Software in 2016.
Steady state and the control group
The steady-state metric should be something users feel, not a server statistic: Netflix uses stream starts per second. Here it is the share of page requests that succeed within the front end's deadline. Comparing the experiment group with a control group drawn from the same traffic at the same time separates the fault's effect from everything else going on: a deploy, a traffic peak, a slow database. The hypothesis in this simulator holds if the experiment group is no more than 0.5 percentage points below control.
Netflix's Chaos Automation Platform, ChAP, works this way: Basiri and colleagues describe putting about 1% of users into an experiment group and another 1% into a control group, routing each to its own small copy of the service, and comparing the two.
Blast radius and stopping early
An experiment in production that finds a weakness has, by definition, hurt someone. The blast radius limits how many: only the experiment group sees the fault, and an automatic check stops the run once that group does clearly worse than control. ChAP stops experiments early when it detects excessive customer impact. The difference is large. With 900 ms added to recommendations:
| Blast radius | Automatic stop | Experiment requests | Requests hurt |
|---|---|---|---|
| 2% | On | 100 | 57 |
| 2% | Off | 1,006 | 545 |
| 50% | Off | 25,190 | 13,593 |
The stop here needs at least 100 requests in each group before it acts, so that a few unlucky requests do not end a harmless experiment. A real platform uses a statistical test for the same purpose and a separate, cruder check for severe harm.
What the default experiment finds
Recommendations are optional, so a slow recommendations service should not break the page. The experiment shows that it does: the front end has 1,000 ms in total, but the recommendations call is allowed to wait up to 1,000 ms and has no fallback. With 900 ms added, only 45.8% of experiment requests succeed, against 100% in control, and 545 of the failures are the page running out of time. A timeout that is longer than the caller's own deadline never fires in time to help.
Setting the recommendations timeout to 250 ms and serving a fallback (a generic list, say) when it fails brings the experiment group to 100%. The retries are still a problem, though: each of the 2 retries waits another 250 ms for a service that is slow on every call, so the p99 is 828 ms against 361 ms in control, and the slow service gets 3 calls per request, tripling the load on the thing that is already struggling. With no retries the p99 is 328 ms and the load 1 call per request.
Other faults find other gaps. With 20% of auth calls failing, auth's single retry leaves 95.2% of requests succeeding, and three retries 99.8%, because retries do help against failures that come and go. A catalog that never answers, with a 500 ms timeout and one retry, uses up the whole page deadline: 0% succeed, and the run is stopped after 100 requests.
Faults worth injecting
- Latency on a dependency. The most revealing fault, because slow is harder to handle than dead: it tests timeouts, deadlines and thread or connection pools.
- Errors from a dependency, all or a share. Tests retries, fallbacks and whether errors are reported to users sensibly.
- Black holes: connections that are accepted and never answered, or packets dropped. Without a timeout, callers wait forever.
- Lost instances or zones: Chaos Monkey's original fault. Tests redundancy, health checks and how fast load moves elsewhere.
- Resource pressure: full disks, CPU or memory exhaustion, clock skew. Often finds monitoring and alerting gaps rather than code bugs.
Common tools include Netflix's Chaos Monkey for instance termination, Shopify's Toxiproxy for network faults between services in tests, Chaos Mesh and LitmusChaos for Kubernetes, and managed services such as AWS Fault Injection Service.
Running experiments in practice
Teams usually start with a game day: a planned session in which people inject a failure into a staging or production system while everyone involved watches, often finding as many problems in dashboards, alerts and runbooks as in the code. Once experiments are routine they are automated and run continuously, so that a regression (a new timeout, a removed fallback) is caught by the next run rather than by the next outage.
Some rules carry over from the method: state the hypothesis before injecting anything; choose a metric that reflects users; keep the blast radius small and widen it only when the results are clean; have a way to stop at once; and fix what you find before moving on to the next experiment.
Chaos engineering questions and answers
What is chaos engineering?
Running controlled experiments that inject real-world failures, such as a slow dependency, errors or a lost server, into a system to see whether it keeps working. The method, set out in the Principles of Chaos Engineering, is to define the steady state in terms of what users experience, predict that it will hold, inject the fault into a small part of real traffic, and look for a difference from a control group.
What is the blast radius of a chaos experiment?
The share of users or requests the experiment can affect. In this simulator's default run, 2% of traffic gets a slow dependency: with the automatic stop on, 57 requests fail before the run halts; with it off, 545 fail; with half of all traffic in the experiment and no stop, 13,593 do.
What is a steady-state hypothesis?
A prediction that a business-level metric, such as successful page loads or stream starts per second, will stay the same during the experiment. It is stated before the fault is injected and checked by comparing the experiment group with a control group that sees the same traffic without the fault.
Why is a timeout longer than the caller's deadline a problem?
Because the caller gives up before the timeout fires, so the timeout never protects anyone. Here the recommendations call may wait 1,000 ms while the page has 1,000 ms in total; adding 900 ms of latency drops the experiment group's success to 45.8%. A 250 ms timeout with a fallback keeps it at 100%.
Do retries help during a chaos experiment?
For errors that come and go, yes: with 20% of auth calls failing, one retry leaves 95.2% of requests succeeding and three retries 99.8%. For a dependency that is slow on every call, retries after a timeout only add waiting and load: the fixed recommendations call with 2 retries makes 3 calls per request and has a p99 of 828 ms; with none, 1 call and 328 ms.
Is chaos engineering done in production?
Eventually, because staging rarely has production's traffic, data and configuration. Teams usually start in staging or with game days, then move to production with a small blast radius, a control group and an automatic stop, as Netflix's ChAP platform does with about 1% of users in each group.
Further reading
- principlesofchaos.orgPrinciples of Chaos EngineeringThe definition, the four steps and the advanced principles.
- Basiri, Hochstein, Jones and TuckerAutomating chaos experiments in productionNetflix's ChAP: experiment and control groups, metrics and stopping early.
- Basiri et al., IEEE SoftwareChaos EngineeringThe original description of the discipline from Netflix.
- Netflix on GitHubChaos MonkeyThe instance-terminating tool that started it.
- Shopify on GitHubToxiproxyA proxy for injecting latency, timeouts and cut connections between services.