7 Injecting failure into the JVM

 

This chapter covers

  • Designing chaos experiments for applications written in Java
  • Injecting failure into a JVM using the java.lang.instrument interface (javaagent)
  • Using free, open source tools to implement chaos experiments

Java is one of the most popular programming languages on planet Earth; in fact, it is consistently placed in the top two or three of many popularity rankings.1 When practicing chaos engineering, you are likely to work with systems written in Java. In this chapter, I’m going to focus on preparing you for that moment.

You’ll start by looking at an existing Java application to come up with ideas for chaos experiments. Then you’ll leverage a unique feature of the Java Virtual Machine (JVM) to inject failure into an existing codebase (without modifying the source code) to implement our experiments. Finally, you’ll cover some existing tools that will allow you to make the whole process easier, as well as some further reading.

By the end of this chapter, you will have learned how to apply chaos engineering practices to any Java program you run into and understand the underlying mechanisms that make it possible to rewrite Java code on the fly. First stop: a scenario to put things in context.

7.1 Scenario

7.1.1 Introducing FizzBuzzEnterpriseEdition

7.1.2 Looking around FizzBuzzEnterpriseEdition

7.2 Chaos engineering and Java

7.2.1 Experiment idea

7.2.2 Experiment plan

7.2.3 Brief introduction to JVM bytecode

7.2.4 Experiment implementation

7.3 Existing tools

7.3.1 Byteman

7.3.2 Byte-Monkey

7.3.3 Chaos Monkey for Spring Boot

7.4 Further reading

Summary