Command Palette

Search for a command to run...

Hectal

Guide G2 · DevOps path

Chaos Engineering

Breaking things on purpose, safely: steady-state hypotheses, blast radius and stop conditions, pod/network/CPU/memory/dependency/zone failure experiments with Chaos Mesh, LitmusChaos, and AWS Fault Injection Service.

Advanced 50 min

Start here

The mental model

A fire drill doesn't start a fire in the kitchen during dinner service. It's announced, controlled, small, and designed to teach you whether the alarms work and people know the exits. Chaos engineering is fire drills for software: you inject a specific failure (kill a pod, add network latency, black out a zone) in a controlled way to learn whether the system and the team respond the way you BELIEVE they do.

The goal is never 'break production'. It's to find weaknesses (a missing retry timeout, an alert that doesn't fire, a failover that takes 10 minutes) in a small, planned experiment, before an uncontrolled real failure finds them for you.

Go deeper

How it works inside

01The experiment loop

1) Define STEADY STATE in business-visible metrics (checkout success rate ≥ 99.5%, p95 latency < 300 ms). 2) Form a HYPOTHESIS: 'if one of three checkout pods is killed, steady state holds'. 3) Choose the smallest BLAST RADIUS that tests it (one pod, in staging first, then a small share of production). 4) Define STOP CONDITIONS (abort automatically if the success rate drops below 99%). 5) Run, observe with your dashboards and traces. 6) Learn: fix what broke, turn the experiment into a regular automated test, and increase scope gradually.

The experiment loopdiagram
Rendering diagram…

02What to break

INFRASTRUCTURE: pod kill, node drain or termination, AZ blackout (subnet network ACL or FIS AZ-availability scenario). NETWORK: added latency, packet loss, partition between two services, DNS failure (Networking course). RESOURCES: CPU stress, memory pressure, disk fill. DEPENDENCIES: a downstream API slow or returning errors, database failover, Kafka broker loss, Redis flush. PEOPLE AND PROCESS: the on-call engineer is unreachable, the runbook link is dead (game days, SRE course).

03Tools

CHAOS MESH (CNCF): Kubernetes CRDs for PodChaos, NetworkChaos, StressChaos, IOChaos, DNSChaos, and TimeChaos, plus Workflows and a dashboard. LITMUSCHAOS (CNCF): a hub of ready-made experiments with 'probes' that check steady state during the run. AWS FAULT INJECTION SERVICE (FIS): managed experiments against AWS resources (stop EC2, fail over RDS/Aurora, throttle APIs, disrupt AZ connectivity, EKS pod actions) with CloudWatch-alarm STOP CONDITIONS and IAM-controlled permissions. Gremlin is a commercial option.

04Doing it safely

Start in non-production. Tell people (a chaos calendar or channel). Use automatic stop conditions tied to SLO alarms. Keep blast radius small (labels, percentages, one AZ). Have the rollback ready. Never run experiments during incidents, big launches, or freezes. Get explicit approval for production experiments, and record results like a postmortem (SRE course), including 'nothing broke', which is also a result.

Do it

Hands-on lab

  1. 1

    Install Chaos Mesh in a test cluster

    Install into its own namespace. Restrict which namespaces it may target with controllerManager.enableFilterNamespace and an annotation on target namespaces.

    terminal
    $ helm repo add chaos-mesh https://charts.chaos-mesh.org
    helm install chaos-mesh chaos-mesh/chaos-mesh -n chaos-mesh --create-namespace --set chaosDaemon.runtime=containerd --set chaosDaemon.socketPath=/run/containerd/containerd.sock --set controllerManager.enableFilterNamespace=true
    kubectl annotate ns shoplite-staging chaos-mesh.org/inject=enabled
    ── expected output ──
    NAME: chaos-mesh
    STATUS: deployed
  2. 2

    Experiment 1: kill a checkout pod

    Hypothesis: with 3 replicas, readiness probes, and a PDB, killing one pod doesn't affect checkout success. Watch your SLO dashboard (Observability course) while it runs.

    chaos/pod-kill-checkout.yamlwhole fileyaml
    apiVersion: chaos-mesh.org/v1alpha1
    kind: PodChaos
    metadata:
      name: kill-one-checkout
      namespace: shoplite-staging
    spec:
      action: pod-kill
      mode: one                     # blast radius: one pod
      selector:
        namespaces: [shoplite-staging]
        labelSelectors: { app: checkout }
    terminal
    $ kubectl apply -f chaos/pod-kill-checkout.yaml
    kubectl -n shoplite-staging get pods -l app=checkout -w
    ── expected output ──
    checkout-6d8f9c7b5-x4k2p 1/1 Terminating 0 3h
    checkout-6d8f9c7b5-p7r2t 0/1 Pending 0 0s
    checkout-6d8f9c7b5-p7r2t 1/1 Running 0 24s
  3. 3

    Experiment 2: slow down a dependency

    Add 800 ms latency to traffic from checkout to the payments service for 5 minutes. Hypothesis: checkout's 2 s timeout and circuit breaker keep p95 under 1.5 s and no threads pile up. This one often fails the first time, which is the point.

    chaos/latency-payments.yamlwhole fileyaml
    apiVersion: chaos-mesh.org/v1alpha1
    kind: NetworkChaos
    metadata:
      name: payments-latency
      namespace: shoplite-staging
    spec:
      action: delay
      mode: all
      selector:
        namespaces: [shoplite-staging]
        labelSelectors: { app: checkout }
      direction: to
      target:
        mode: all
        selector:
          namespaces: [shoplite-staging]
          labelSelectors: { app: payments }
      delay: { latency: 800ms, jitter: 100ms }
      duration: 5m
  4. 4

    Experiment 3: an AZ failure with AWS FIS

    The FIS AZ availability scenario disrupts networking for one AZ's subnets and can stop instances and fail over databases there. The STOP CONDITION is a CloudWatch alarm on the checkout SLO: if it fires, FIS halts and reverts. Run in staging first.

    terminal
    $ aws fis start-experiment --experiment-template-id EXT1a2b3c4d5e6f --tags purpose=az-gameday
    aws fis get-experiment --id EXP9z8y7x6w5v --query 'experiment.state'
    ── expected output ──
    { "status": "running", "reason": "Experiment is running." }

Operate it

Knobs that matter

SettingDefaultWhat it doesWhen to change it
mode (Chaos Mesh)—How many targets: one, all, fixed, fixed-percent, random-max-percent.Start with one; widen only after it passes.
durationuntil deletedHow long the fault lasts.Always set one, so a forgotten experiment ends by itself.
Stop conditions (FIS)noneCloudWatch alarms that abort the experiment.Mandatory for anything beyond staging; tie to SLO alarms.
Namespace filteroffWhich namespaces chaos may touch.Enable and opt in namespaces explicitly.

3am practice

Failure drills

Each drill is a real failure mode. Read the scenario and the output, decide what's wrong, then reveal the diagnosis.

Drill #1

Latency experiment takes down the whole site

Experiment 2 (800 ms to payments) runs in staging. Within two minutes, not just checkout but the product pages time out.

terminal
$ kubectl -n shoplite-staging logs deploy/checkout | grep -m1 -i pool
── what you'll see ──
HikariPool-1 - Connection is not available, request timed out after 30000ms (total=10, active=10, idle=0, waiting=187)

The bigger picture

Connects to

Prove it

Interview questions

01

What is chaos engineering?

02

How do you run chaos experiments in production safely?