Video in progress

Staff 🧪 Testing

What is the difference between fault injection tests and chaos engineering, and when does it make sense to start a chaos practice in an organization?

Fault injection tests are deterministic tests in CI that check a specific hypothesis (for example, if the database drops, the service returns 503). Chaos engineering is system-level experiments in a real or prod-like environment. It's best to start chaos once observability, automatic recovery, and who does what during an incident are in place.

📖 Answer

Fault injection is an extension of ordinary tests. With Toxiproxy you add 2 seconds of latency to Postgres and check: does the connection pool run out, does the circuit breaker open, is the chain of timeouts right (an upstream timeout must not be larger than the downstream one). The result is yes/no, every day in CI.

Chaos engineering answers a different question: "what don't we know?" The hypothesis is at the system level: "if one AZ goes away, payment success doesn't fall below 99%". An experiment starts with a small "blast radius", the steady-state metrics are watched, and the hypothesis is either confirmed or broken.

Preconditions to start (without them chaos just produces incidents):

  • metrics and alerts at the service and business level, otherwise you won't see the outcome of the experiment;
  • automatic restarts, health checks, several replicas;
  • a way to stop the experiment instantly (a kill switch);
  • an on-call, and an agreement on who does what in an incident.

The usual sequence I build:

  1. Fault injection tests in CI: timeout, retry and circuit breaker configuration.
  2. A "game day" on staging: experiments planned with the team, by hand.
  3. Small automated experiments in prod during working hours, with one pod or one replica.

In practice the most value comes from the first step: misconfigured timeouts, retry storms, fallbacks that never worked. All of that can be found without a chaos platform. Unless you're a large organization, don't rush to the third stage.