Implementing Chaos Engineering

1. Injecting Latency Delays

Example: Istio fault injection

apiVersion: networking.istio.io/v1
kind: VirtualService
metadata: { name: orders-chaos }
spec:
  hosts: [orders]
  http:
    - fault:
        delay:
          percentage: { value: 10 }
          fixedDelay: 5s
      route: [{ destination: { host: orders } }]

2. Simulating Service Failures

FailureTool
Pod killchaos-mesh PodChaos, kube-monkey
Network partitionNetworkChaos, Toxiproxy
Process killSIGKILL injection
DNS failureDNSChaos resolve errors
Disk pressureStressChaos fill /tmp

3. Implementing Random Error Injection

Example: Envoy fault filter

http_filters:
  - name: envoy.filters.http.fault
    typed_config:
      "@type": type.googleapis.com/envoy.extensions.filters.http.fault.v3.HTTPFault
      abort:
        percentage: { numerator: 1, denominator: HUNDRED }
        http_status: 503
      delay:
        percentage: { numerator: 5, denominator: HUNDRED }
        fixed_delay: 2s

4. Using Traffic Shadowing

AspectDetail
PurposeTest new version with real traffic
Mirror %Start at 1-5%
Response handlingDiscarded, never returned to client
Side effectsRisk: writes to real DB → use sandbox
Comparisondiff old vs new responses

5. Configuring Fault Injection Rules

ScopeDetail
User filterHeader x-chaos: true
PercentageStart small (1%)
DurationTime-boxed window
Blast radiusOne region/cell first
Kill switchDisable in < 30s

6. Setting Up Circuit Breaker Testing

TestExpected
Trigger 5 consecutive 5xxCB opens
Subsequent requestsFast-fail without backend hit
After cooldownHalf-open, one trial
Success in half-openCB closes
Fallback responseCached or default

7. Implementing Timeout Simulation

LayerInject
Networktc netem delay 30s
ApplicationSleep in handler
ProxyfixedDelay > client timeout
DBpg_sleep(N) injected query

8. Using Resource Exhaustion Tests

ResourceStress Tool
CPUstress-ng --cpu N
Memorystress --vm-bytes
Disk I/Ofio
File descriptorsOpen N sockets
Connection poolExhaust DB pool

9. Configuring Partial Outage Scenarios

ScenarioValidate
1 of 3 AZs downQuorum maintained, traffic shifts
Cache downGraceful origin fallback
Auth downCached token validation
DB read-replica lagStale-read tolerance
Region isolationFailover within RTO

10. Setting Up Chaos Mesh Integration

Example: Chaos Mesh NetworkChaos

apiVersion: chaos-mesh.org/v1alpha1
kind: NetworkChaos
metadata: { name: delay-orders }
spec:
  action: delay
  mode: all
  selector:
    namespaces: [prod]
    labelSelectors: { app: orders }
  delay:
    latency: "200ms"
    correlation: "25"
    jitter: "50ms"
  duration: "5m"