Chaos engineering
One server of three is switched off on purpose. Follow the experiment from prediction to surprise to fix, and see why teams break their own systems before chance does.
In 30 seconds
Chaos engineering means deliberately injecting failures, such as a dead server or a slow network, into a running system to see whether it copes as expected.
It is run as an experiment: describe the normal behaviour as a measurable number, predict that it will hold, then try to prove the prediction wrong. The blast radius is kept small, with a way to stop at once.
A failed prediction is the prize: a weakness found on a quiet day instead of during a real outage. Netflix’s Chaos Monkey made this routine by switching off servers at random.
Chaos engineering, step by step
Invented numbers, rounded (200 of 300 is 66.7 %). Real experiments also inject slowness, network faults and failed dependencies, and need good monitoring in place first.
- Step 1: Failures will happen. A shop runs on three servers behind a load balancer, each taking 100 of the 300 requests per second. Its normal, healthy behaviour, the steady state, is a number you can measure: at least 99 % of requests succeed. Machines will fail sooner or later, and nobody is sure what the number does then.
- Step 2: State a hypothesis. An experiment starts with a prediction that could turn out false. Each server can handle 200 requests per second, so if B dies, A and C should absorb its share and users should notice nothing. Writing the expected result down first is what makes this an experiment rather than vandalism.
- Step 3: Limit the blast radius. The blast radius is how much can be hurt if the prediction is wrong. Keep it as small as will still teach something: one server, in working hours, with the team watching and a stop rule that ends the experiment and restarts B if users suffer for too long.
- Step 4: Inject the failure. Server B is switched off on purpose. The load balancer has not noticed, so it keeps sending B its 100 requests per second and every one of them fails. Only 200 of 300 requests succeed, about 67 %. The prediction said 99 %.
- Step 5: Observe the result. The success rate stays near 67 % for 30 seconds, then recovers, short of the 60 seconds that would trigger the stop rule. The cause: the load balancer checks server health only every 30 seconds. The hypothesis is disproved, which is the useful outcome. A weakness was found on a calm morning, not in a real outage.
- Step 6: Fix it, run it again. The team shortens the health check to 2 seconds and has the load balancer retry a failed request on another server. The same experiment now passes: A and C carry 150 each and the success rate stays above 99 %. Next the experiment can grow, to two servers or a whole data centre.
- Step 7: Chaos Monkey. Netflix built Chaos Monkey around 2010, while moving to the cloud. It switches off randomly chosen servers in the live system during working hours. Because losing a server became routine, every team had to build services that survive it, and engineers were at their desks when a weakness showed.
Try it yourself
Learn this first
- Load balancersOne address, many servers: how requests are shared out and dead servers skipped. Beginner
- ObservabilityWorking out what a system is doing inside from the logs, metrics and traces it emits. Beginner
- SLIs, SLOs and SLAsWhat you measure, what you aim for and what you promise, with an error budget worked out. Beginner
Learn next
- Circuit breaker patternA switch that stops calls to a failing service so the failure cannot spread. Intermediate
- Disaster recovery (RPO and RTO)How much data you can lose, how long you can be down, and what each costs. Intermediate
- AutoscalingA group of servers grows and shrinks with traffic, steered by a metric and two rules. Intermediate
Spotted a mistake on this page?