I just released a small library to put some troubles in my Node.JS Express applications.

https://github.com/drouian-m/express-chaos-middleware

How to use it ?

Add the dependency to the project.

npm add express-chaos-middleware

Then load the module in the express application :

const { chaos } = require('express-chaos-middleware');

app.use(chaos());

After that the chaos module will be triggered on every route call and goes randomly:

  • slow down the application
  • return http errors
  • throw exceptions

Probabilities of having issues and the randomly triggered effects can be configured with the input param object ((see documentation))[https://github.com/drouian-m/express-chaos-middleware#usage]

Effects

Here are some results of library effects observable with a Grafana dashboard.

This picture is a screenshot of a Grafana dashboard. In this dashboard, there are four graphs: average routes response time, number of requests per minute, number of failed requests over time grouped by 4xx and 5xx codes and the last one is the overlay of valid and error requests. This dashboard demonstrates that when the chaos module is enabled, it creates latency and http errors. We can see the latency and the number of failed requests growing on the graphs.