days
-7
0
hours
-1
-2
minutes
-2
-5
seconds
-1
-3
search

Chaos Monkey comes to Spring Boot

Jane Elizabeth
© Shutterstock / Luis Molinero

Cry havoc and let slip the monkeys of chaos! Chaos engineering comes to Spring Boot with a bang. Is your Spring Boot project ready to be tested by the simian army of doom? Find out now!

Chaos theory, as immortalized by the great Ian Malcom, deals with unpredictability in complex systems. Specifically, anything can happen and does. But what does that have to do with programming? Chaos engineering means building a resilient system that can handle absolutely anything that production throws at it.

Initially conceived by Netflix in 2011, Chaos Monkey was developed into a robust way to test your code and your disaster recovery system. By regularly “killing” random instances, developers could test their project’s architecture to make sure it was robust enough to keep from noticeably impacting production or the end users.

Imagine a monkey entering a “data center”, these “farms” of servers that host all the critical functions of our online activities. The monkey randomly rips cables, destroys devices and returns everything that passes by the hand. The challenge for IT managers is to design the information system they are responsible for so that it can work despite these monkeys, which no one ever knows when they arrive and what they will destroy.

Chaos Monkeys by Antonio Garcia Martinez

When the Chaos Monkey randomly kills processes, it shows whether your system can handle random attacks or natural disasters. But the processes aren’t actually permanently damaged – just temporarily down. The code remains safe… although you might find out that it needs some serious work.

SEE MORE: Netflix unleashes Chaos Monkey

Chaos Monkey in Spring Boot

So, what does Chaos Monkey in Spring Boot look like? Basically, you integrate chaos-monkey as a dependency in your project. And, once that dependency is activated, you watch those crazy monkeys go to work.

If you’ve lain awake at night wondering if your fallbacks really work or what really happens if one of your services breaks down, then the chaos monkeys are right for you. But, communication is key. Do yourself a favor and warn your coworkers before you let slip the monkeys.

Chaos-monkey will automatically scan your application for all classes annotated with any of the following Spring annotations:

  • @Controller
  • @RestController
  • @Service
  • @Repository

By configuration, you define which assaults and watcher are activated, per default only the @Service watcher and the latency assault are activated.

chaos monkey

Helpfully, it comes with a watcher component that scans your app for any of the following Spring annotations:

  • @Controller
  • @RestController
  • @Service
  • @Repository

With the help of Spring AOP, Chaos Monkey recognizes the execution of a public method and will either not execute any action or start one of its assaults.

The chaos monkey can also provide any of the following assaults:

  • Latency Assault
  • Exception Assault
  • AppKiller Assault

If you’re interested in having a crazed simian attack your architecture, head on over to the Chaos Monkey in Spring Boot page or find it on GitHub. This project is still under development, so there may be bugs.

If you do choose the way of the monkey, good luck and godspeed.

Author
Jane Elizabeth
Jane Elizabeth is an assistant editor for JAXenter.com.