CHAOS MONKEY ALTERNATIVES

Spring Boot

READ TIME
Last Updated
October 17, 2018

Chaos Monkey for Spring Boot

Chaos Monkey for Spring Boot is an open-source tool written in Java that is installed as either an internal or external dependency at startup. Spring Boot for Chaos Monkey can perform three types of Assaults: Latency, Exception, and KillApplication. Assaults are triggered based on Watcher components that monitor @Controller, @RestController, @Service, @Repository, and @Component Spring Boot annotations.

A Watcher can only be triggered by public method calls, which can then execute a configured Assault. A Latency Assault adds random latency to the request, an Exception Assault randomly throws a Runtime Exception, and a KillApplication Assault kills the Spring Boot application.

A few minimal Assault and Watcher settings can be configured via chaos.monkey properties, as listed below.

PropertyDescriptionTypeDefault
chaos.monkey.enabledToggle Chaos MonkeyBooleanFALSE
chaos.monkey.assaults.levelAssault severityInteger (1-10)5
chaos.monkey.assaults.latencyRangeStartMinimum latency (MS) added to requestInteger3000
chaos.monkey.assaults.latencyRangeEndMaximum latency (MS) added to requestInteger15000
chaos.monkey.assaults.latencyActiveToggle Latency AssaultBooleanTRUE
chaos.monkey.assaults.exceptionsActiveToggle Exception AssaultBooleanFALSE
chaos.monkey.assaults.killApplicationActiveToggle KillApplication AssaultBooleanFALSE
chaos.monkey.watcher.controllerToggle Controller WatcherBooleanFALSE
chaos.monkey.watcher.restControllerToggle RestController WatcherBooleanFALSE
chaos.monkey.watcher.serviceToggle Service WatcherBooleanTRUE
chaos.monkey.watcher.repositoryToggle Repository WatcherBooleanFALSE
chaos.monkey.watcher.componentToggle Component WatcherBooleanFALSE

Most are self-explanatory, but the Assault severity level property (chaos.monkey.assaults.level) actually determines two things: The number of requests between Assaults, and also how many Assaults will occur at that time. Thus, a default level of 5 means that 5 Assaults will occur on every fifth request.

Configuration properties can be changed at runtime via the HTTP endpoints. For example, sending JSON configuration data to the /chaosmonkey/assaults endpoint can be used to modify future Assault configurations.

JSON

{
  "level": 2,
  "latencyRangeStart": 2500,
  "latencyRangeEnd": 7500,
  "latencyActive": true,
  "exceptionsActive": true,
  "killApplicationActive": true,
  "restartApplicationActive": true,
  "watchedCustomServices": [
    "com.example.chaos.monkey.chaosdemo.controller.HelloController.sayHello"
  ]
}

Check out the reference guide for more information on getting Chaos Monkey for Spring Boot up and running.

Injecting Failure in Spring Boot Applications with Gremlin

Gremlin makes it easy to execute thoughtful Chaos Experiments within your standalone Spring-based applications, including those built with Spring Boot. Rather than inject itself directly into your application's Java code Gremlin performs attacks against the instances powering your application. Gremlin gives you the power to see how the system responds to overloaded CPU and memory and terminated instances.

Running your first Chaos Experiment with Gremlin is as simple as signing up for a Gremlin account, installing the Gremlin agent on the targeted instances, and then launching attacks via either the web UI or API.

Chaos Engineering with Fabric8 and Spring Boot

The Fabric8 development platform has first-class support for building Spring Boot applications and comes with a built-in Chaos Monkey app. The Fabric8 Chaos Monkey is capable of deleting pods within Kubernetes/OpenShift applications.

To get started in the Fabric8 console navigate to Apps, click Run..., select the Chaos Monkey app, and run it. Once the Chaos Monkey app is running within your Fabric8 Sprint Boot deployment you can configure Chaos Monkey using a few options.

  • Chaos Monkey Excludes: A comma-separated regex pattern list indicating which pods are not eligible for deletion.
  • Chaos Monkey Includes: A comma-separated regex pattern list indicating which pods are eligible for deletion.
  • Chaos Monkey Frequency Seconds: The delay between each pod deletion.

You can also optionally run the ChatOps app and set the Chaos Monkey Room configuration option to indicate which chat room Chaos Monkey should communicate with. The Chaos Monkey app will then post notifications of its actions in chat.

BASH

# CHAT OUTPUT EXAMPLE
added replicationController chaos-monkey
added pod chaos-monkey-2fahv
Chaos Monkey is starting in namespace default with include patterns 'fabric8mq*' exclude patterns 'chat*' and a kill frequency of 30 seconds.  Here I come!
Chaos Monkey killed pod fabric8mq-consumer-7hwe1 in namespace default

Previous
Chaos Monkey
Next
DOWNLOAD PDF