Chaos engineering tools activate features like stopping virtual machines or terminating pods in your Kubernetes cluster. The Cloud Bug Study states that neglected error handling - buggy code, timeouts, etc. - accounts for the vast majority of system malfunction.
Chaos Middleware allows you to inject turbulent conditions into your application. It lets you delay or raise errors when handling requests, and by applying additional conditions, you can decrease the blast radius of your attack.
The following sections will guide you through: i) the installation and configuration process of Chaos Middleware in your Spring Boot application and ii) simulation of delays and application faults.
Installation & configuration
1. Install the Chaos Middleware by including following dependency in your spring boot application pom.xml
.
<dependency>
<groupId>io.proofdock</groupId>
<artifactId>spring-boot-starter-chaos-middleware</artifactId>
<version>0.1.4</version>
</dependency>
2. Add an application name to the application.properties
.
chaos.middleware.application-name=webshop-order
3. Start your application.
Simulate delays
The delay attack introduces delays to the request/response cycle. This type of the attack enables you to verify the behavior of your system in case of timeouts or slow responses.
Trigger delays by setting the x-proofdock-attack request header. The Chaos Middleware detects any value inside this header and injects appropriate turbulent conditions.
To simulate delay, set the x-proofdock-attack header's value to
{"actions":[{"name":"delay", "value":"5"}], "target":{ "application":"webshop-order"}}
- name - set delay attack
- value - delay response by 5 seconds
- target - target application name
Let's attack an application using Postman.
Simulate faults
The fault attack injects an exception into your code. This type of the attack enables you to verify the behavior of your application in case of an unexpected event.
Trigger faults by setting the x-proofdock-attack request header.
{"actions":[{"name":"fault", "value":"java.lang.Exception"}], "target":{ "application":"webshop-order"}}
- name - set fault attack
-
value - thow exception of the type
java.lang.Excpetion
- target - the targeted application name
Let's attack an application using Postman.
Chaos Panel for Azure DevOps users
A more convenient way to control such attacks is the usage of the Chaos Panel provided by Proofdock's Chaos Platform. The Chaos Platform extends the Azure DevOps with chaos engineering capabilities. The Chaos Panel allows you to control application attacks via a graphical user interface.
The Chaos Panel in Azure DevOps
Check out the docs, if you are interested in the Chaos Platform.
Thank you
We hope you enjoyed reading this article and got a new perspective on resilience.
We are Proofdock, a software tech company located in Germany, created to help engineers build more resilient and reliable software products. Check out the Chaos Platform for Microsoft Azure and explore your system.
Article photo by Raychel Sanner on Unsplash
Top comments (0)