Distributed systems / Chaos engineering

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.

Intermediate7 steps~6 min
Load balancer — shares requests between the servers
Server — answers requests, up to 200 a second
Injected failure — the fault switched on deliberately
// THE SHORT VERSION

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

STEPS01 / 07

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 01 / 07 Failures will happen
THE MATH
steady state: 300 req/s, 100 per server success ≥ 99 %
  1. 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.
  2. 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.
  3. 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.
  4. 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 %.
  5. 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.
  6. 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.
  7. 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.
VALUES SO FAR
traffic300 req/sinput
capacity200/s eachinput
expected····guess
radius····limit
measured····result
lost····result
cause····finding
rerun····result

Spotted a mistake on this page?