chaos-engineering

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese
<objective> Chaos engineering is the discipline of experimenting on a system to build confidence in its ability to withstand turbulent conditions. It is not random destruction -- it is hypothesis-driven, controlled experimentation that reveals weaknesses before they cause outages. A retry that "works in the demo" silently double-charges customers when the payment API times out; the only way to know is to inject the timeout and watch. </objective>
<objective> 混沌工程是通过在系统上开展实验,来建立对系统承受动荡环境能力信心的学科。它不是随机破坏——而是基于假设的受控实验,能够在弱点引发故障之前将其暴露出来。比如在演示中“正常工作”的重试机制,当支付API超时可能会静默地向客户重复收费;唯一能发现这个问题的方法就是注入超时故障并观察系统表现。 </objective>

Quick Route

快速指引

SituationGo to
First experiment ever, team is newStarting Small → First Three Experiments
Designing one experimentChaos Experiment Workflow (5 steps)
Picking a tool for your environmentTools → Choosing a tool decision tree
Running a team sessionGame Day Planning
Need runnable injection commands/configs
references/fault-injection.md
Want the abort to fire without a human
references/fault-injection.md
→ Automated abort

场景跳转至
首次开展实验,团队是新手从小处着手 → 前三个实验
设计单个实验混沌实验工作流(5步)
为你的环境选择工具工具 → 工具选择决策树
开展团队会话Game Day规划
需要可运行的注入命令/配置
references/fault-injection.md
希望无需人工干预即可触发中止
references/fault-injection.md
→ 自动中止

Discovery Questions

探索问题

Check
.agents/qa-project-context.md
first. If it exists, use it as context and skip questions already answered there.
Environment and readiness:
  • Where will chaos experiments run? (Pre-production only, production with approval, never production)
  • What is the team's monitoring maturity? Can you detect problems in real time?
  • Has the team practiced incident response? Is there a runbook?
  • Is there executive buy-in for chaos engineering? (Important for production experiments)
Architecture:
  • What is the architecture? (Monolith, microservices, serverless, hybrid)
  • What are the critical dependencies? (Database, cache, message queue, third-party APIs)
  • Are there single points of failure? (Single database, single region, no redundancy)
  • What redundancy and failover mechanisms exist?
Current resilience practices:
  • Do services have health checks? What do they check?
  • Are there circuit breakers, retry logic, or timeout configurations?
  • What happens when a dependency is unavailable? (Graceful degradation, hard failure, unknown)
  • Have you experienced unexpected outages? What failed?
Team and culture:
  • Is the team comfortable with controlled failure? (Anxiety is normal and should be addressed)
  • Who would be the chaos engineering champion? (Needs someone to own the practice)
  • What is the appetite for starting? (Start small or dive in)

首先查看
.agents/qa-project-context.md
。如果该文件存在,请将其作为上下文,并跳过已在其中回答的问题。
环境与就绪性:
  • 混沌实验将在何处运行?(仅预生产环境、需审批的生产环境、绝不用于生产环境)
  • 团队的监控成熟度如何?能否实时检测问题?
  • 团队是否演练过事件响应流程?是否有运行手册?
  • 管理层是否支持混沌工程?(这对生产环境实验至关重要)
架构:
  • 系统架构是什么类型?(单体应用、微服务、无服务器、混合架构)
  • 关键依赖项有哪些?(数据库、缓存、消息队列、第三方API)
  • 是否存在单点故障?(单一数据库、单一区域、无冗余)
  • 现有哪些冗余和故障转移机制?
当前韧性实践:
  • 服务是否包含健康检查?检查内容是什么?
  • 是否有断路器、重试逻辑或超时配置?
  • 依赖项不可用时会发生什么?(优雅降级、硬故障、未知情况)
  • 是否经历过意外故障?故障点是什么?
团队与文化:
  • 团队是否能接受受控故障?(焦虑是正常现象,需要妥善处理)
  • 谁将担任混沌工程负责人?(需要专人负责该实践)
  • 团队的启动意愿如何?(从小处着手还是全面推进)

Core Principles

核心原则

1. Hypothesis-driven: define expected behavior before injecting

1. 基于假设:注入故障前定义预期行为

Every chaos experiment starts with a hypothesis: "We believe that if [failure X occurs], the system will [expected behavior Y]." Without a hypothesis, you are just breaking things. The hypothesis names concrete steady-state metrics (baseline metrics) — error rate, latency, throughput — and the bound each may move to.
Example hypothesis: "We believe that if the primary database becomes unavailable, the application will serve cached data for read requests and queue write requests for up to 5 minutes without user-visible errors. Blast radius: staging, one service. Steady-state baseline: error rate <0.1%, P95 latency <300ms."
每个混沌实验都始于一个假设:“我们认为,如果[故障X发生],系统将[出现预期行为Y]。”没有假设的实验只是单纯破坏系统。假设需明确具体的稳态指标(基线指标)——错误率、延迟、吞吐量——以及每个指标允许的波动范围。
示例假设:“我们认为,如果主数据库不可用,应用将为读请求提供缓存数据,并将写请求排队最多5分钟,且不会出现用户可见的错误。影响范围:预生产环境,单个服务。稳态基线:错误率<0.1%,P95延迟<300ms。”

2. Start small: one service, controlled blast radius

2. 从小处着手:单个服务,受控影响范围

The first chaos experiment should not be "shut down production." It should be "add 200ms latency to one non-critical service in staging." Increase scope gradually as confidence and tooling mature.
首个混沌实验不应是“关闭生产环境”,而应是“在预生产环境中为一个非关键服务增加200ms延迟”。随着信心和工具成熟度提升,逐步扩大实验范围。

3. Monitoring is a prerequisite

3. 监控是先决条件

If you cannot detect problems in real time, you cannot safely inject failures. Chaos experiments without monitoring are just outages with extra steps. Verify dashboards, alerts, and on-call processes before running any experiment.
如果无法实时检测问题,就无法安全地注入故障。没有监控的混沌实验只是多了步骤的故障。在运行任何实验之前,需验证仪表盘、告警和值班流程是否正常工作。

4. Game days build muscle memory

4. Game Day培养肌肉记忆

Running chaos experiments in automated pipelines is valuable, but game days -- scheduled sessions where the team runs experiments together and practices response -- build the human skills that matter during real incidents.

在自动化流水线中运行混沌实验很有价值,但Game Day——即团队共同运行实验并演练响应的预定会话——能培养实际事件中至关重要的人为技能。

Chaos Experiment Workflow

混沌实验工作流

Every chaos experiment follows this five-step process.
每个混沌实验都遵循以下五步流程。

Step 1: Define steady state hypothesis

步骤1:定义稳态假设

Identify the metrics that define "normal" and predict what should happen during the experiment.
Experiment: Database failover
Steady state:
  - Error rate: < 0.1%
  - P95 latency: < 300ms
  - Successful orders per minute: > 50

Hypothesis: When the primary database fails over to the replica,
  - Error rate will spike to < 2% for < 30 seconds
  - P95 latency will increase to < 1s for < 60 seconds
  - No orders will be permanently lost
  - The application will recover without manual intervention
确定定义“正常状态”的指标,并预测实验期间应出现的情况。
Experiment: Database failover
Steady state:
  - Error rate: < 0.1%
  - P95 latency: < 300ms
  - Successful orders per minute: > 50

Hypothesis: When the primary database fails over to the replica,
  - Error rate will spike to < 2% for < 30 seconds
  - P95 latency will increase to < 1s for < 60 seconds
  - No orders will be permanently lost
  - The application will recover without manual intervention

Step 2: Introduce the variable

步骤2:引入变量

Inject the failure in a controlled way with a clear scope and duration.
Injection:
  Target: primary database (PostgreSQL)
  Method: block TCP port 5432 on the primary instance
  Scope: single database instance
  Duration: 60 seconds
  Blast radius: staging environment only (first run)

  Abort conditions:
    - Error rate > 10% for > 2 minutes
    - Any data corruption detected
    - Manual abort by experiment owner
以受控方式注入故障,明确范围和持续时间。
Injection:
  Target: primary database (PostgreSQL)
  Method: block TCP port 5432 on the primary instance
  Scope: single database instance
  Duration: 60 seconds
  Blast radius: staging environment only (first run)

  Abort conditions:
    - Error rate > 10% for > 2 minutes
    - Any data corruption detected
    - Manual abort by experiment owner

Step 3: Observe

步骤3:观察

During the experiment, monitor all relevant metrics in real time. Assign observers to specific dashboards.
Observation assignments:
  - Engineer A: application error rate and latency dashboard
  - Engineer B: database metrics (connections, replication lag, failover status)
  - Engineer C: application logs (search for database connection errors)
  - Engineer D: business metrics (order count, payment processing)
实验期间,实时监控所有相关指标。为观察者分配特定仪表盘。
Observation assignments:
  - Engineer A: application error rate and latency dashboard
  - Engineer B: database metrics (connections, replication lag, failover status)
  - Engineer C: application logs (search for database connection errors)
  - Engineer D: business metrics (order count, payment processing)

Step 4: Analyze recovery and data integrity

步骤4:分析恢复与数据完整性

After the experiment, analyze what happened versus what was expected.
Analysis checklist:
  - Did the system behave as hypothesized? (Y/N, with details)
  - How long was the impact? (Expected vs. actual duration)
  - Were any errors visible to users?
  - Was any data lost or corrupted?
  - Did monitoring and alerting detect the problem correctly?
  - How long before alerts fired?
  - What was the recovery time?
实验结束后,分析实际发生的情况与预期情况的差异。
Analysis checklist:
  - Did the system behave as hypothesized? (Y/N, with details)
  - How long was the impact? (Expected vs. actual duration)
  - Were any errors visible to users?
  - Was any data lost or corrupted?
  - Did monitoring and alerting detect the problem correctly?
  - How long before alerts fired?
  - What was the recovery time?

Step 5: Fix and iterate

步骤5:修复与迭代

Document findings, fix resilience gaps, and schedule a re-run to verify the fix.
Findings document:
  Experiment: Database failover (2026-03-20)
  Hypothesis: Confirmed / Partially confirmed / Disproved
  Recovery time: 45s (expected vs actual: expected <10s, actual 45s)
  Data integrity: no rows lost; 3 writes returned 500 instead of queueing

  Findings:
    - Connection pool did not detect stale connections for 45 seconds (expected: <10s)
    - Retry logic worked correctly for read operations
    - Write operations returned 500 errors for 38 seconds (expected: queued)

  Action items (every one has an owner and a due date — no item is deferred):
    - [ ] Configure connection pool health checks — assigned to @maria, due 2026-03-31
    - [ ] Implement write queue with 5-minute buffer — assigned to @dan, due 2026-04-02
    - [ ] Re-run experiment after fixes deployed (re-run scheduled 2026-04-03);
          specific metrics to check on re-run: stale-connection detection <10s,
          zero write 500s, error rate <2%

记录发现的问题,修复韧性缺口,并安排重新运行实验以验证修复效果。
Findings document:
  Experiment: Database failover (2026-03-20)
  Hypothesis: Confirmed / Partially confirmed / Disproved
  Recovery time: 45s (expected vs actual: expected <10s, actual 45s)
  Data integrity: no rows lost; 3 writes returned 500 instead of queueing

  Findings:
    - Connection pool did not detect stale connections for 45 seconds (expected: <10s)
    - Retry logic worked correctly for read operations
    - Write operations returned 500 errors for 38 seconds (expected: queued)

  Action items (every one has an owner and a due date — no item is deferred):
    - [ ] Configure connection pool health checks — assigned to @maria, due 2026-03-31
    - [ ] Implement write queue with 5-minute buffer — assigned to @dan, due 2026-04-02
    - [ ] Re-run experiment after fixes deployed (re-run scheduled 2026-04-03);
          specific metrics to check on re-run: stale-connection detection <10s,
          zero write 500s, error rate <2%

Failure Injection Types

故障注入类型

Network failures

网络故障

FailureToolUse Case
Latency injectiontc, toxiproxy, GremlinSimulate slow network, distant regions
Packet losstc netem, Chaos MeshSimulate unreliable network
DNS failureiptables, CoreDNS manipulationSimulate DNS outage
Network partitioniptables, Chaos MeshSimulate split-brain scenarios
Bandwidth restrictiontc, toxiproxySimulate congested network
See
references/fault-injection.md
for the
tc netem
latency/packet-loss commands and the toxiproxy latency config.
故障类型工具适用场景
延迟注入tc, toxiproxy, Gremlin模拟慢速网络、跨区域场景
丢包tc netem, Chaos Mesh模拟不可靠网络
DNS故障iptables, CoreDNS manipulation模拟DNS中断
网络分区iptables, Chaos Mesh模拟脑裂场景
带宽限制tc, toxiproxy模拟网络拥堵
有关
tc netem
延迟/丢包命令和toxiproxy延迟配置,请查看
references/fault-injection.md

Service failures

服务故障

FailureMethodUse Case
Service crashKill process, pod deleteSimulate unexpected crash
Service slowdownCPU stress, thread pool exhaustionSimulate overloaded service
Error injectionReturn 500/503, throw exceptionsSimulate application errors
Memory pressurestress-ng, Chaos MeshSimulate memory leaks
See
references/fault-injection.md
for the
kubectl delete pod
command and the LitmusChaos pod-delete ChaosEngine manifest.
故障类型方法适用场景
服务崩溃终止进程、删除Pod模拟意外崩溃
服务变慢CPU压力测试、线程池耗尽模拟过载服务
错误注入返回500/503、抛出异常模拟应用错误
内存压力stress-ng, Chaos Mesh模拟内存泄漏
有关
kubectl delete pod
命令和LitmusChaos的Pod删除ChaosEngine清单,请查看
references/fault-injection.md

Infrastructure failures

基础设施故障

FailureMethodUse Case
Disk fullfallocate, ddSimulate disk exhaustion
CPU exhaustionstress-ngSimulate CPU saturation
Memory exhaustionstress-ngSimulate OOM conditions
Clock skewchrony manipulation, timedatectlSimulate time drift
See
references/fault-injection.md
for the
fallocate
disk-fill and
stress-ng
CPU/memory commands.
故障类型方法适用场景
磁盘满fallocate, dd模拟磁盘耗尽
CPU耗尽stress-ng模拟CPU饱和
内存耗尽stress-ng模拟OOM(内存不足)情况
时钟偏移chrony manipulation, timedatectl模拟时间漂移
有关
fallocate
磁盘填充和
stress-ng
CPU/内存命令,请查看
references/fault-injection.md

Dependency failures

依赖项故障

FailureMethodUse Case
API downtoxiproxy, mock serverSimulate third-party outage
Database unavailableblock port, kill processSimulate database outage
Cache unavailableblock Redis portSimulate cache miss storm
Message queue fullfill queue, block consumersSimulate backpressure
See
references/fault-injection.md
for the programmatic toxiproxy integration test that disables Redis and asserts graceful degradation.

故障类型方法适用场景
API不可用toxiproxy, mock server模拟第三方服务中断
数据库不可用阻塞端口、终止进程模拟数据库中断
缓存不可用阻塞Redis端口模拟缓存击穿风暴
消息队列满填充队列、阻塞消费者模拟背压场景
有关程序化toxiproxy集成测试(禁用Redis并验证优雅降级)的内容,请查看
references/fault-injection.md

Tools

工具

ToolTypeBest For
LitmusChaos (3.29.x)Kubernetes-native, CNCFK8s environments, CI/CD integration; ChaosCenter UI; Workflows for GameDay-as-code; MCP Server (Oct 2025) drives experiments from an AI assistant
Chaos Mesh (2.8.x)Kubernetes-native, CNCFK8s with fine-grained control; eBPF chaos via
bpfki
runtime for kernel-precision faults
AWS FISManaged AWS serviceCloud-chaos for AWS workloads (EC2, ECS, RDS, EKS); CloudWatch-alarm stop-conditions for auto-abort — primary cloud-native option
GremlinManaged platformTeams wanting guided experiments + compliance reporting; Health Checks halt-and-rollback on SLO breach
SteadybitManaged platformReliability hub spanning Kubernetes + cloud + on-prem; direct alternative to Gremlin
kube-monkeyOpen sourceLightweight K8s alternative when Litmus/Chaos Mesh feel heavy
PumbaOpen sourceDocker-only chaos (containers, networks); pre-K8s and edge
toxiproxyNetwork proxy, open sourceNetwork fault injection in integration tests
tc (traffic control)Linux kernelNetwork latency and packet loss
stress-ngLinux utilityCPU, memory, disk stress testing
k6 (+ xk6-disruptor)Load testing toolCombined load + chaos scenarios
Avoid: Chaos Monkey (Netflix) for new projects — low activity, Spinnaker-only path (as of mid-2026). It still works and the repo is not archived, but it only injects instance termination and requires a Spinnaker deployment pipeline. Greenfield work should pick Chaos Mesh, LitmusChaos, or AWS FIS. (The older SimianArmy repo was archived in 2021; don't confuse the two.)
工具类型最佳适用场景
LitmusChaos (3.29.x)Kubernetes原生、CNCF项目K8s环境、CI/CD集成;ChaosCenter UI;Game Day即代码工作流;MCP Server(2025年10月版本)支持通过AI助手驱动实验
Chaos Mesh (2.8.x)Kubernetes原生、CNCF项目需要细粒度控制的K8s环境;通过
bpfki
运行时实现eBPF混沌,提供内核级精度的故障注入
AWS FISAWS托管服务AWS工作负载(EC2、ECS、RDS、EKS)的云混沌测试;支持CloudWatch告警停止条件实现自动中止——首选云原生方案
Gremlin托管平台需要引导式实验+合规报告的团队;健康检查可在SLO违规时中止并回滚
Steadybit托管平台覆盖Kubernetes+云+本地环境的可靠性中心;Gremlin的直接替代方案
kube-monkey开源工具当Litmus/Chaos Mesh过于繁重时,轻量级K8s替代方案
Pumba开源工具仅Docker环境的混沌测试(容器、网络);适用于K8s之前的环境和边缘场景
toxiproxy网络代理、开源工具集成测试中的网络故障注入
tc (traffic control)Linux内核工具网络延迟和丢包测试
stress-ngLinux工具CPU、内存、磁盘压力测试
k6 (+ xk6-disruptor)负载测试工具组合负载+混沌场景测试
注意:新项目避免使用Chaos Monkey(Netflix)——活跃度低,仅支持Spinnaker部署流程(截至2026年年中)。 该工具仍可使用,仓库未归档,但仅能注入实例终止故障,且需要Spinnaker部署流水线。新项目应选择Chaos Mesh、LitmusChaos或AWS FIS。(旧版SimianArmy仓库已于2021年归档;请勿混淆二者。)

Choosing a tool

工具选择决策树

Decision tree:
  Running on Kubernetes?
    → Cloud-managed AWS workloads: AWS FIS (cloud-native, IAM-integrated)
    → On K8s with sidecar tolerance: Chaos Mesh (eBPF, fine-grained)
    → On K8s wanting workflows + UI: LitmusChaos (ChaosCenter, Workflows)
    → On K8s lightweight: kube-monkey

  Running on plain VMs / Docker?
    → Docker only: Pumba
    → Linux: tc + stress-ng (manual)

  Need network fault injection in integration tests?
    → toxiproxy (lightweight, programmatic API)

  Need to combine load testing with chaos?
    → k6 with xk6-disruptor extension

  Need managed platform with UI and compliance?
    → Gremlin or Steadybit (both commercial)
Decision tree:
  Running on Kubernetes?
    → Cloud-managed AWS workloads: AWS FIS (cloud-native, IAM-integrated)
    → On K8s with sidecar tolerance: Chaos Mesh (eBPF, fine-grained)
    → On K8s wanting workflows + UI: LitmusChaos (ChaosCenter, Workflows)
    → On K8s lightweight: kube-monkey

  Running on plain VMs / Docker?
    → Docker only: Pumba
    → Linux: tc + stress-ng (manual)

  Need network fault injection in integration tests?
    → toxiproxy (lightweight, programmatic API)

  Need to combine load testing with chaos?
    → k6 with xk6-disruptor extension

  Need managed platform with UI and compliance?
    → Gremlin or Steadybit (both commercial)

GameDay-as-code

Game Day即代码

The 2026 trend is treating chaos as scheduled CI jobs rather than ad-hoc events: Litmus Workflows, Steadybit reliability hub, and Gremlin Scenarios all let you define a chaos run as YAML and trigger it from CI on a cron. Pair with the Game Day Planning section below — the human practice still matters; the automation just removes the bottleneck of "we never had time to schedule one." For a concrete cron-gated pipeline (nightly pod-delete on an off-peak window) plus automated abort/stop-condition examples, see
references/fault-injection.md
.
LitmusChaos shipped an MCP Server in October 2025 that connects an AI assistant such as Claude directly to ChaosCenter: you can list, run, and stop experiments in natural language ("run pod-delete on the frontend pods," "stop the network latency experiment") instead of hand-writing YAML. Relevant if your team already drives ops through an AI agent.

2026年的趋势是将混沌实验视为定时CI任务,而非临时事件:Litmus Workflows、Steadybit可靠性中心和Gremlin Scenarios都支持将混沌运行定义为YAML,并通过CI定时触发。结合下方的Game Day规划部分——人为实践仍然重要;自动化只是消除了“我们没时间安排”的瓶颈。有关定时触发的流水线(非高峰时段夜间Pod删除)以及自动中止/停止条件示例,请查看
references/fault-injection.md
LitmusChaos在2025年10月推出了MCP Server,可将Claude等AI助手直接连接到ChaosCenter:你可以用自然语言列出、运行和停止实验(如“在前端Pod上运行Pod删除实验”、“停止网络延迟实验”),无需手动编写YAML。如果你的团队已通过AI Agent运维,该功能非常实用。

Game Day Planning

Game Day规划

A game day is a scheduled session where the team runs chaos experiments together, practices incident response, and builds confidence in the system's resilience.
Game Day是预定的会话,团队共同运行混沌实验,演练事件响应,增强对系统韧性的信心。

Preparation checklist

准备清单

2 weeks before:
  - [ ] Define 2-3 experiments to run (don't overload the schedule)
  - [ ] Write hypotheses for each experiment
  - [ ] Get approval from engineering leadership and affected teams
  - [ ] Notify support team and stakeholders
  - [ ] Verify monitoring and alerting are working
  - [ ] Identify rollback procedures for each experiment
  - [ ] Schedule 3-4 hour block (experiments + analysis + retro)

1 day before:
  - [ ] Confirm all participants and their roles
  - [ ] Test that fault injection tools work in the target environment
  - [ ] Verify rollback procedures work (dry run)
  - [ ] Prepare dashboards and observation assignments
  - [ ] Brief the on-call team
  - [ ] Confirm abort criteria for each experiment
2周前:
  - [ ] 定义2-3个要运行的实验(不要安排过多内容)
  - [ ] 为每个实验编写假设
  - [ ] 获取工程负责人和受影响团队的批准
  - [ ] 通知支持团队和相关利益方
  - [ ] 验证监控和告警正常工作
  - [ ] 确定每个实验的回滚流程
  - [ ] 安排3-4小时的时间段(实验+分析+回顾)

1天前:
  - [ ] 确认所有参与者及其角色
  - [ ] 测试故障注入工具在目标环境中正常工作
  - [ ] 验证回滚流程有效(预演)
  - [ ] 准备仪表盘和观察任务分配
  - [ ] 向值班团队简要说明情况
  - [ ] 确认每个实验的中止标准

Communication and roles

沟通与角色

Communicate before (schedule, scope, abort authority), during (live updates every 15 minutes in a dedicated channel), and after (summary within 24 hours with findings and action items).
Assign roles per experiment: experiment owner (runs it, makes abort decisions), observers (application metrics, infrastructure metrics, logs, user experience), and a scribe (records timeline and decisions).
实验前(日程、范围、中止权限)、实验期间(专用频道每15分钟更新一次)、实验后(24小时内发布包含发现和行动项的总结)都需进行沟通。
为每个实验分配角色:实验负责人(运行实验、做出中止决策)、观察者(应用指标、基础设施指标、日志、用户体验)、记录员(记录时间线和决策)。

Post-game retrospective

事后回顾

For each experiment: was the hypothesis confirmed? What surprised us? What action items do we have? For the process: did monitoring detect problems? Did alerts fire? Were we comfortable with the blast radius? Close with action items (with owners and due dates) and schedule the next game day.

针对每个实验:假设是否得到验证?有哪些意外发现?需要采取哪些行动?针对流程:监控是否检测到问题?告警是否触发?我们对影响范围是否满意?最后确定行动项(明确负责人和截止日期)并安排下一次Game Day。

Starting Small: First Three Experiments

从小处着手:前三个实验

For teams new to chaos engineering, start with these three experiments in a pre-production environment.
对于混沌工程新手团队,先在预生产环境中开展以下三个实验。

Experiment 1: Slow database

实验1:数据库变慢

Why first: Database latency is the most common cause of user-facing slowness, and the experiment is easy to set up and reverse.
Hypothesis: When database latency increases by 500ms, the application
will remain functional with response times under 3 seconds.

Injection: Add 500ms latency to the database connection using toxiproxy.
Duration: 5 minutes.
Environment: staging.

What to observe:
  - Application response times (should increase by ~500ms, not 10x)
  - Connection pool behavior (should not exhaust connections)
  - Timeout handling (requests should not hang indefinitely)
  - Circuit breaker activation (if implemented)
  - Cache effectiveness (cached reads should be unaffected)
**为何首选:**数据库延迟是导致用户端变慢的最常见原因,且该实验易于设置和撤销。
Hypothesis: When database latency increases by 500ms, the application
will remain functional with response times under 3 seconds.

Injection: Add 500ms latency to the database connection using toxiproxy.
Duration: 5 minutes.
Environment: staging.

What to observe:
  - Application response times (should increase by ~500ms, not 10x)
  - Connection pool behavior (should not exhaust connections)
  - Timeout handling (requests should not hang indefinitely)
  - Circuit breaker activation (if implemented)
  - Cache effectiveness (cached reads should be unaffected)

Experiment 2: Third-party API returns 500s

实验2:第三方API返回500错误

Why second: Third-party dependencies fail regularly, and the application's handling of those failures is often untested.
Hypothesis: When the payment provider returns 500 errors, the
application will show a user-friendly error message and allow
retry without duplicate charges.

Injection: Configure mock/proxy to return 500 for payment API calls.
Duration: 10 minutes.
Environment: staging.

What to observe:
  - Error message quality (user-friendly, not stack traces)
  - Retry behavior (does the application retry? How many times?)
  - Idempotency (retries don't create duplicate transactions)
  - Fallback (is there an alternative payment path?)
  - Monitoring (does the payment failure show up in alerts?)
**为何第二:**第三方依赖项经常故障,而应用对这些故障的处理往往未经过测试。
Hypothesis: When the payment provider returns 500 errors, the
application will show a user-friendly error message and allow
retry without duplicate charges.

Injection: Configure mock/proxy to return 500 for payment API calls.
Duration: 10 minutes.
Environment: staging.

What to observe:
  - Error message quality (user-friendly, not stack traces)
  - Retry behavior (does the application retry? How many times?)
  - Idempotency (retries don't create duplicate transactions)
  - Fallback (is there an alternative payment path?)
  - Monitoring (does the payment failure show up in alerts?)

Experiment 3: Cache unavailable

实验3:缓存不可用

Why third: Cache failures cause "thundering herd" problems where all traffic suddenly hits the database, often causing cascading failures.
Hypothesis: When Redis becomes unavailable, the application will fall
back to direct database queries with degraded but functional performance.

Injection: Block Redis port using toxiproxy or iptables.
Duration: 5 minutes.
Environment: staging.

What to observe:
  - Database query volume (should increase but not overwhelm)
  - Response times (should increase but remain under 5 seconds)
  - Error rate (cache miss should not cause errors)
  - Connection pool (database connections should not exhaust)
  - Recovery (when cache returns, does the application resume normal behavior?)

**为何第三:**缓存故障会导致“惊群效应”,即所有流量突然涌入数据库,往往引发级联故障。
Hypothesis: When Redis becomes unavailable, the application will fall
back to direct database queries with degraded but functional performance.

Injection: Block Redis port using toxiproxy or iptables.
Duration: 5 minutes.
Environment: staging.

What to observe:
  - Database query volume (should increase but not overwhelm)
  - Response times (should increase but remain under 5 seconds)
  - Error rate (cache miss should not cause errors)
  - Connection pool (database connections should not exhaust)
  - Recovery (when cache returns, does the application resume normal behavior?)

Anti-Patterns

反模式

Chaos without monitoring

无监控的混沌实验

Injecting failures without the ability to observe their impact is not chaos engineering -- it is sabotage. You will not know if the experiment revealed a problem until a user complains.
Fix: Before any chaos experiment, verify that you can see error rates, latency, throughput, and dependency health in real time. If you cannot, invest in monitoring first. Go one step further and wire the monitor into the experiment so it auto-aborts on breach — AWS FIS CloudWatch stop-conditions, Gremlin Health Checks, or a Litmus
promProbe
in
mode: Continuous
(see
references/fault-injection.md
).
在无法观察故障影响的情况下注入故障,不是混沌工程——而是破坏行为。直到用户投诉,你才会知道实验是否暴露了问题。
**解决方法:**在开展任何混沌实验之前,验证是否能实时查看错误率、延迟、吞吐量和依赖项健康状况。如果不能,先投入资源建设监控。更进一步,将监控与实验关联,使其在指标违规时自动中止——比如AWS FIS CloudWatch停止条件、Gremlin健康检查,或Litmus的
promProbe
mode: Continuous
模式,查看
references/fault-injection.md
)。

Starting too big

起步规模过大

The first chaos experiment should not be "kill the production database." Starting with high-impact experiments before the team has practiced with low-impact ones creates anxiety and potential real outages.
Fix: Start with staging. Start with non-critical services. Start with reversible injections (latency, not data corruption). Build confidence gradually. Graduate to production only after multiple successful staging experiments.
首个混沌实验不应是“终止生产环境数据库”。在团队未演练过低影响实验的情况下,就开展高影响实验会引发焦虑,并可能导致实际故障。
**解决方法:**从预生产环境开始。从非关键服务开始。从可撤销的注入(延迟,而非数据损坏)开始。逐步建立信心。只有在多次预生产实验成功后,才推进到生产环境。

No rollback plan

无回滚计划

"The experiment is only 60 seconds, we don't need a rollback plan." Then the fault injection tool crashes and the failure persists indefinitely (exactly how a 5-minute
tc
latency injection becomes a 2-hour outage when the command fails midway).
Fix: Every experiment must have a documented rollback procedure that can be executed in under 30 seconds. Test the rollback before running the experiment, and have a second person ready to abort if the experiment owner is unable to. Prefer a tool-enforced stop-condition over a human finger on the kill switch (see Automated abort in
references/fault-injection.md
) — and pick injections with a built-in timeout (
stress-ng --timeout
, Litmus
TOTAL_CHAOS_DURATION
) so the fault self-clears even if nobody is watching.
“实验仅持续60秒,我们不需要回滚计划。”然后故障注入工具崩溃,故障持续存在(比如5分钟的
tc
延迟注入因命令中途失败,变成了2小时的故障)。
**解决方法:**每个实验都必须有记录在案的回滚流程,且能在30秒内完成。在运行实验前测试回滚流程,并安排另一人在实验负责人无法操作时随时准备中止。优先选择工具强制执行的停止条件,而非人工触发中止(查看
references/fault-injection.md
中的自动中止)——并选择带有内置超时的注入(
stress-ng --timeout
、Litmus
TOTAL_CHAOS_DURATION
),即使无人监控,故障也会自动清除。

Chaos in production without approval

未经批准在生产环境开展混沌实验

Running chaos experiments in production without explicit approval from engineering leadership and affected teams destroys trust and careers.
Fix: Before any production run: get explicit, documented engineering leadership approval; send affected teams notification and brief the on-call team and support team; communicate scope and duration and share the abort criteria with named abort authority; and confirm the blast radius is bounded to the smallest viable target. Start with staging first. Anything skipped here is what turns a controlled experiment into an incident.
未经工程负责人和受影响团队明确批准,就在生产环境开展混沌实验会破坏信任,甚至影响职业发展。
**解决方法:**在任何生产环境实验之前:获得工程负责人明确的书面批准;通知受影响团队,并向值班团队和支持团队简要说明情况;沟通实验范围、持续时间,并与指定的中止负责人共享中止标准;确认影响范围限制在最小可行目标。先从预生产环境开始。任何跳过的步骤都可能将受控实验变成事件。

Running chaos experiments during incidents

在事件期间开展混沌实验

Adding controlled failures to a system that is already experiencing problems makes diagnosis harder and extends the outage.
Fix: Cancel or postpone chaos experiments if the system is not in steady state. Check for active incidents before starting. If an unrelated incident starts during an experiment, abort the experiment immediately.
在系统已出现问题时添加受控故障,会增加诊断难度并延长故障时间。
**解决方法:**如果系统未处于稳态,取消或推迟混沌实验。开始前检查是否有活跃事件。如果实验期间发生无关事件,立即中止实验。

No follow-through on findings

对发现的问题无后续行动

The experiment revealed that the circuit breaker does not work correctly. The team says "interesting" and moves on. The finding is never fixed. The next real outage triggers the same failure.
Fix: Every chaos experiment finding gets a ticket with an owner and a due date. Re-run the experiment after the fix to verify. Track the backlog of chaos findings alongside production incident action items.

实验发现断路器无法正常工作。团队说“有意思”然后继续推进。问题从未得到修复。下次实际故障会触发相同的失败。
**解决方法:**每个混沌实验发现的问题都要创建工单,明确负责人和截止日期。修复后重新运行实验以验证效果。将混沌实验发现的问题与生产事件行动项一起跟踪管理。

Verification

验证

Prove the safety machinery works before trusting a single live experiment — an abort path you have never triggered is a hypothesis, not a control. Smallest check first:
  1. Inject and reverse in staging. Run the lowest-blast-radius injection (e.g.
    tc qdisc add dev eth0 root netem delay 200ms
    ) against one staging service, confirm the steady-state dashboard moves, then run the documented rollback (
    tc qdisc del dev eth0 root
    ) and confirm metrics return to baseline. Time the rollback — it must complete inside its stated window (under 30s).
  2. Trip the automated abort. Force the monitored metric past its threshold (push error rate over the stop-condition) on an experiment wired to AWS FIS CloudWatch stop-conditions, a Gremlin Health Check, or a Litmus
    promProbe
    in
    mode: Continuous
    . Confirm the experiment halts on its own with no human action. If it does not fire, the abort is unverified (see
    references/fault-injection.md
    ).
  3. Confirm the self-clearing timeout. Start a bounded injection (
    stress-ng --cpu 4 --timeout 60s
    , or Litmus
    TOTAL_CHAOS_DURATION: '60'
    ), then walk away. Confirm the fault clears itself at the deadline even if nobody aborts.
  4. Confirm the findings loop closes. After a staging run, confirm a findings doc was produced with baseline-vs-actual numbers and that every gap became a tracked ticket with an owner — the experiment record is the artifact, not the injection.
If steps 1–3 cannot be demonstrated in staging, the experiment is not safe to promote toward production.

在信任任何实时实验之前,先证明安全机制有效——从未触发过的中止路径只是假设,而非控制措施。先从最小的检查开始:
  1. 在预生产环境中注入并撤销故障。 对一个预生产服务运行影响范围最小的注入(如
    tc qdisc add dev eth0 root netem delay 200ms
    ),确认稳态仪表盘发生变化,然后运行记录的回滚命令(
    tc qdisc del dev eth0 root
    ),确认指标恢复基线。记录回滚时间——必须在规定的窗口内完成(30秒以内)。
  2. 触发自动中止。 在关联了AWS FIS CloudWatch停止条件、Gremlin健康检查或Litmus
    promProbe
    mode: Continuous
    模式)的实验中,强制监控指标超过阈值(如错误率超过停止条件)。确认实验无需人工干预即可自行停止。如果未触发,则中止机制未通过验证(查看
    references/fault-injection.md
    )。
  3. 验证自动清除超时。 启动一个有时间限制的注入(
    stress-ng --cpu 4 --timeout 60s
    ,或Litmus
    TOTAL_CHAOS_DURATION: '60'
    ),然后离开。确认即使无人中止,故障也会在截止时间自动清除。
  4. 验证发现闭环。 预生产实验结束后,确认生成了包含基线与实际数据对比的发现文档,且每个缺口都变成了有负责人的跟踪工单——实验记录是核心成果,而非注入操作。
如果步骤1-3无法在预生产环境中完成验证,则实验不能推广到生产环境。

Done When

完成标准

  • Every experiment has a written hypothesis ("We believe that if [failure X], the system will [expected behavior Y]") recorded before any fault is injected
  • Blast radius is explicitly bounded — target scope, duration, and abort conditions are written in the experiment record, and no experiment runs in production before at least one passing run of the same experiment in staging
  • A steady-state snapshot (dashboard link or the actual baseline metric values) is attached to each experiment record, captured immediately before injection
  • A findings doc exists per experiment with baseline-vs-actual numbers, recovery time, and an explicit data-integrity check (lost/corrupted: yes/no)
  • Each weakness found has a tracked ticket with a named owner, a due date, and a scheduled re-run of the same experiment to verify the fix
  • 每个实验在注入故障前都有书面假设(“我们认为,如果[故障X],系统将[出现预期行为Y]”)
  • 明确界定影响范围——实验记录中写明目标范围、持续时间和中止条件,且任何生产环境实验必须先在预生产环境成功运行至少一次
  • 每个实验记录都附有稳态快照(仪表盘链接或实际基线指标值),在注入故障前立即捕获
  • 每个实验都有发现文档,包含基线与实际数据对比、恢复时间,以及明确的数据完整性检查(是否丢失/损坏:是/否)
  • 发现的每个弱点都有跟踪工单,明确负责人、截止日期,并安排重新运行相同实验以验证修复效果

Reference Files (in
references/
)

参考文件(位于
references/
目录)

  • fault-injection.md — Runnable commands, configs, and test code for injecting each failure class:
    tc netem
    and toxiproxy network faults,
    kubectl
    /LitmusChaos service faults (ChaosEngine with
    engineState: active
    ),
    fallocate
    /
    stress-ng
    infrastructure faults, the programmatic toxiproxy dependency-failure test, plus automated abort / stop-condition examples (AWS FIS, Gremlin, Litmus probes, Litmus MCP) and a cron-gated continuous-chaos CI job.
  • fault-injection.md — 各类故障注入的可运行命令、配置和测试代码:
    tc netem
    和toxiproxy网络故障、
    kubectl
    /LitmusChaos服务故障(
    engineState: active
    的ChaosEngine)、
    fallocate
    /
    stress-ng
    基础设施故障、程序化toxiproxy依赖项故障测试,以及自动中止/停止条件示例(AWS FIS、Gremlin、Litmus探针、Litmus MCP)和定时触发的持续混沌CI任务。

Related Skills

相关技能

  • testing-in-production — for safe-rollout mechanics during a release (feature flags, canary, dark launch). Chaos engineering deliberately breaks things to find weaknesses; testing-in-production controls exposure so a breakage stays contained. Go there for the rollout, here for the fault injection.
  • observability-driven-testing — when production telemetry (traces, logs, error patterns) is the input that tells you which tests or experiments to design. It feeds the hypothesis; chaos engineering then proves or disproves it. Observability is also a hard prerequisite for safe chaos.
  • performance-testing — load testing complements chaos; combine load + fault for realistic failure scenarios (see k6 + xk6-disruptor).
  • release-readiness — chaos experiment results feed into go/no-go release confidence assessments.
  • test-environments — pre-production environments are the safe starting point for chaos experiments.
  • qa-metrics — chaos experiment results (recovery time, error impact) are quality metrics worth tracking.
  • testing-in-production — 用于发布期间的安全发布机制(功能标志、金丝雀发布、暗发布)。混沌工程故意破坏系统以发现弱点;生产环境测试控制影响范围,使破坏得到遏制。发布相关内容请查看该技能,故障注入相关内容请查看本技能。
  • observability-driven-testing — 当生产遥测数据(链路追踪、日志、错误模式)作为输入,指导你设计哪些测试或实验时。它为假设提供依据;混沌工程则验证或推翻假设。可观测性也是安全开展混沌实验的硬性先决条件。
  • performance-testing — 负载测试与混沌测试互补;结合负载+故障可实现更真实的故障场景(查看k6 + xk6-disruptor)。
  • release-readiness — 混沌实验结果为发布就绪性的通过/不通过评估提供依据。
  • test-environments — 预生产环境是混沌实验的安全起点。
  • qa-metrics — 混沌实验结果(恢复时间、错误影响)是值得跟踪的质量指标。