How to Use Chaos Monkey to Test Infrastructure Resilience
How Chaos Monkey works, what it needs (Spinnaker, MySQL, cron), safe configuration defaults, a first experiment plan, and when to use AWS FIS instead.
Chaos Monkey tests infrastructure resilience by randomly terminating virtual machine instances in production during working hours. If your service keeps working while instances disappear, it is resilient to that failure. Netflix's open source version runs on a schedule through cron, uses Spinnaker to find instances, and stores termination history in MySQL.
This guide explains how Chaos Monkey works, what it needs, how to configure it safely, and how to turn its random terminations into real resilience findings. It also covers when a managed service such as AWS Fault Injection Service is a better fit. For the wider practice behind it, see how chaos engineering improves DevOps pipeline resilience.
Key takeaways
- Chaos Monkey has one job: it randomly terminates instances. It does not inject latency, fill disks or break networks.
- The open source version requires Spinnaker, MySQL 5.6 or later, a Go toolchain to build it, and cron. It does not run as a service.
- By default it is disabled, leashed (it logs instead of terminating), and limited to working hours in a configured time zone.
- Per-app settings in Spinnaker control the mean time between terminations (default two days), the minimum time between terminations (default one day) and how instances are grouped.
- Run it only after you have a measurable steady state and alerts that tell you when users are affected.
- Instance termination is the simplest failure. Use broader fault injection tools once your service survives it.
What Chaos Monkey is and why it exists
Netflix's documentation describes Chaos Monkey as responsible for randomly terminating instances in production to ensure that engineers implement their services to be resilient to instance failures. The idea is simple. In a cloud environment, any virtual machine can disappear without warning. If that is going to happen anyway, it is better to make it happen on purpose, during working hours, when engineers are at their desks and can fix what breaks.
Doing this regularly changes how teams build. If you know an instance in your group may be killed any working day, you stop storing state on local disks, you make sure the load balancer drops dead instances quickly, and you keep enough spare capacity to absorb the loss. Those are exactly the properties that also protect you when a real hardware failure or zone problem hits.
Chaos Monkey is one implementation of the broader discipline described on Principles of Chaos Engineering: define a steady state, form a hypothesis that it will hold, introduce a real-world event, and look for a difference. Instance termination is the real-world event Chaos Monkey introduces.
How Chaos Monkey works
The open source Chaos Monkey is a Go program, not a long-running daemon. The deployment guide says it does not run as a service. Instead, a daily cron job runs on weekdays and creates a termination schedule. That schedule creates further cron jobs that carry out the terminations during working hours.
For each enabled group, on each work day, Chaos Monkey flips a biased coin. If the coin comes up in favour, it picks a random instance from the group and terminates it. The bias is set by the mean time between terminations. The database enforces the minimum gap, so even several Chaos Monkey deployments sharing one database will not terminate more than allowed.
| Component | Role |
|---|---|
| Spinnaker | Source of truth for apps, clusters and instances; holds per-app Chaos Monkey settings |
| MySQL 5.6 or later | Stores termination history and enforces minimum time between terminations |
| cron | Runs the daily scheduler and the individual termination jobs |
| Termination script | Called by each scheduled job; path set by chaosmonkey.term_path |
| etcd or Consul (optional) | Dynamic properties such as chaosmonkey.enabled without redeploying |
Prerequisites
The Netflix deployment guide lists these requirements:
- Spinnaker, with Deck version v2839.0 or later and the
chaosMonkey: truefeature flag enabled in Deck's settings file. - MySQL version 5.6 or later.
- A Go toolchain to build the
chaosmonkeybinary. - cron on the host that runs it.
The Spinnaker dependency is the biggest practical hurdle. If your organization does not deploy with Spinnaker, Chaos Monkey cannot discover your instances, and you are better served by a tool that fits your platform. We cover alternatives later in this guide.
Configuring Chaos Monkey
The configuration file
Chaos Monkey reads a TOML file. The example from the project's documentation looks like this:
[chaosmonkey]
enabled = true
schedule_enabled = true
leashed = false
accounts = ["production", "test"]
[database]
host = "dbhost.example.com"
name = "chaosmonkey"
user = "chaosmonkey"
encrypted_password = "securepasswordgoeshere"
[spinnaker]
endpoint = "http://spinnaker.example.com:8084"
The defaults are deliberately cautious. According to the configuration reference, enabled defaults to false, schedule_enabled to false, and leashed to true. A leashed Chaos Monkey records what it would have terminated without actually terminating anything. Terminations happen between start_hour (default 9) and end_hour (default 15) in time_zone (default America/Los_Angeles). Teams outside that time zone should set their own so terminations land in their working day.
One detail in the docs is easy to miss: despite its name, the encrypted_password field takes the plain password, because only a no-op decryptor ships with Chaos Monkey. Protect the configuration file accordingly, or supply your own decryptor.
Per-app settings in Spinnaker
Each application opts in through the Chaos Monkey widget on its Config tab in Spinnaker. The settings are:
- Enabled: turns Chaos Monkey on or off for the app.
- Mean time between terminations: defaults to two days. On average, one instance per group is terminated every two working days.
- Minimum time between terminations: defaults to one day. Chaos Monkey never terminates more than once a day per group.
- Grouping: app, stack or cluster. This defines what counts as one group for the limits above.
- Exceptions: combinations of account, region, stack and detail to exclude. A
*matches everything. - Regions are independent: on by default. Turning it off stops Chaos Monkey terminating instances of the same group in different regions, which the docs suggest for databases that replicate across regions.
Opt-in per application is a sensible design. Teams decide when they are ready, and the platform team can track adoption.
Running your first experiment safely
Turning Chaos Monkey on is easy. Learning something from it takes preparation. A sequence that works for most teams:
- Define steady state. Pick a user-facing metric such as successful requests per second or error rate, and know its normal range. The Principles of Chaos Engineering recommend measuring system output rather than internal details.
- Write the hypothesis. For example: "If one instance in the checkout cluster is terminated, the error rate stays within its normal range and the group replaces the instance within its usual launch time."
- Run leashed first. Leave
leashed = truefor a week and review which instances would have been terminated. This catches surprises such as an important singleton you forgot to exclude. - Start in a test account. Add only a non-production account to
accounts, enable one app, and watch the results. - Check the basics. Is the group behind a load balancer with health checks? Does autoscaling replace terminated instances? Does anyone get paged, and should they?
- Move to production gradually. Enable one low-risk app with default timings. Expand only when terminations have stopped producing surprises.
- Record findings. Each termination that caused user impact is a bug to fix, with a ticket and an owner.
The question of when an organization is mature enough for production chaos experiments is discussed in when to implement chaos engineering in production.
What instance termination reveals
Even a simple instance kill tends to uncover a familiar list of weaknesses:
Local state
Sessions, uploads or caches stored on the instance's disk disappear with it. Users get logged out or lose work. The fix is to move state to a shared store.
Slow failover
If load balancer health checks are too lenient, traffic keeps going to a dead instance for longer than users will tolerate. Tightening the health check interval and threshold reduces the window.
Missing capacity headroom
A group running at high utilization with no spare instance cannot absorb a loss. Remaining instances overload and the failure spreads. The fix is either more headroom or faster scaling.
Hidden singletons
A scheduler, a leader process or a cron host that runs on exactly one instance is a single point of failure. Chaos Monkey finds these quickly. Leader election or a managed scheduler removes them.
Slow bootstrapping
If a replacement instance takes a long time to download dependencies and warm caches, the group runs short for that time. Baking more into the machine image or container shortens it.
Alerting gaps
Sometimes the service survives but nobody can tell a termination happened, or every termination pages someone at their desk for no reason. Both are useful findings about your monitoring.
Reading the results
After each termination, compare the steady-state metric for the affected group against the same period on a normal day. If the error rate or latency moved outside its normal range, you have a finding. If it did not, check that the termination really happened and that a replacement instance came up, because a quiet dashboard can also mean the experiment silently failed. Look at how long the group ran below its desired size, how many requests failed during that window, and whether any alert fired. Over a few weeks these numbers show whether the service is getting more tolerant of instance loss or whether the same weakness keeps appearing. Share the trend with the owning team rather than only individual incidents, so that the fixes compete fairly with feature work in planning.
Limits of Chaos Monkey
Chaos Monkey tests one failure mode. Real outages also come from added latency, packet loss, DNS failures, exhausted disks, expired certificates, overloaded dependencies and whole zone or region problems. The open source Chaos Monkey documentation covers instance termination only.
It is also tied to Spinnaker. Teams on Kubernetes without Spinnaker, or on serverless platforms, need something else. And because it terminates at random, it is not suited to targeted experiments where you want to test one specific hypothesis on one specific component at one specific time.
These limits are not a reason to skip it. Surviving random instance loss is the foundation. Once your services pass that test routinely, move on to richer experiments. Our post on how chaos experiments expose toolchain weaknesses shows how to apply the same thinking to CI/CD systems.
Alternatives for broader fault injection
AWS Fault Injection Service
AWS FIS is a managed service for fault injection experiments on AWS workloads. You create an experiment template that contains actions, targets and stop conditions. Targets can be chosen by resource ID or by tags and state. Stop conditions are CloudWatch alarms: if an alarm fires during the experiment, FIS stops it. That guardrail is something you would have to build yourself around Chaos Monkey.
AWS's documentation warns that FIS carries out real actions on real resources and strongly recommends a planning phase and pre-production runs before production experiments. That advice applies to every chaos tool.
Kubernetes-native tools
On Kubernetes, Chaos Mesh and LitmusChaos, both CNCF incubating projects, run experiments as custom resources inside the cluster, including pod kills, network faults and stress tests. Choose based on what your platform team already runs and supports.
Simple scripts
For a first experiment you do not need any framework. Terminating one instance from a test group by hand, while watching dashboards, teaches most of the same lessons. Tools add scheduling, guardrails and repeatability.
Making chaos part of normal operations
Resilience testing works best when it is routine rather than a special event. Some practices help:
- Keep a log of every experiment, its hypothesis and its result, next to your postmortems.
- Treat findings like incidents: fix them, and re-run the experiment to confirm the fix.
- Run game days where the team watches a planned experiment together, especially for new services.
- Include chaos results in reliability reviews alongside SLO performance. The SRE role in this is covered in the role of SREs in DevOps teams.
Architecture matters too. Asynchronous, event-driven designs tend to tolerate instance loss better than chains of synchronous calls, because a message waits in a queue until a healthy consumer picks it up. Our guide to event-driven architectures for DevOps pipelines explains that design. For a broader list of reliability tooling, see top SRE tools for beginners.
To practice autoscaling groups, load balancer health checks and fault injection on real AWS infrastructure, our AWS DevOps Engineer Professional training runs in the Kharadi, Pune classroom and live online across India.
Frequently asked questions
What does Chaos Monkey do?
It randomly terminates virtual machine instances, by default in working hours on weekdays, so that teams build services that keep working when an instance fails.
What does Chaos Monkey need to run?
The Netflix deployment guide lists Spinnaker with Chaos Monkey enabled in Deck, MySQL 5.6 or later, a Go toolchain to build the binary, and cron for scheduling.
Is Chaos Monkey safe to run in production?
It is designed for production, but only after you have tested it leashed and in non-production accounts, have clear steady-state metrics, and have excluded components that cannot yet survive termination.
How often does Chaos Monkey terminate instances?
Per app, Spinnaker settings default to a mean time between terminations of two days and a minimum of one day per group.
What does leashed mode mean?
A leashed Chaos Monkey records which instances it would have terminated without terminating them. It is the default, and a good way to preview behaviour.
Can I use Chaos Monkey without Spinnaker?
Not the open source version, which relies on Spinnaker for app and instance information. Without Spinnaker, look at AWS Fault Injection Service or Kubernetes-native chaos tools.
How is AWS FIS different from Chaos Monkey?
AWS FIS is a managed service with many fault actions, tag-based targeting and CloudWatch alarm stop conditions. Chaos Monkey only terminates instances at random on a schedule.
References
What's Your Reaction?
Like
0
Dislike
0
Love
0
Funny
0
Angry
0
Sad
0
Wow
0