Small knowledge, big challenge! This article is participating in the creation activity of “Essential Tips for Programmers”.

This article has participated in the “Digitalstar Project” and won a creative gift package to challenge the creative incentive money.

One, foreword

I’m using some tools of chaos engineering these days, so I’ll sort them out for reference.

Later, I will arrange other tools when I have time, and write one by one. Idle is idle anyway.

I’m not in the habit of writing a regular column. So just be casual.

Ii. Prerequisites

There is an application for SpringBoot.

Three, specific operation

  1. Add the dependent
<dependency>
        <groupId>de.codecentric</groupId>
        <artifactId>chaos-monkey-spring-boot</artifactId>
        <version>2.3.1</version>
</dependency>
Copy the code
  1. configurationapplication.yml
chaos:
  monkey:
    # start the monkey
    enabled: true
    assaults:
      # determine how many requests are attacked. 5: Attacks every 5 requests
      level: 5
      # Increase the minimum delay in milliseconds
      latency-range-start: 5000
      # Increase the maximum delay in milliseconds
      latency-range-end: 10000
      # Delayed attack starts
      latency-active: true
      # Abnormal attack started
      exceptions-active: true
      # kill Start the application
      kill-application-active: true
    watcher: # Control range
      controller: false
      rest-controller: false
      service: true
      repository: false # (JDBC and JPA)
      component: false
Copy the code
  1. Add startup Parameters

  1. Run the project

  1. Access interface

Look, there’s an eight-second response time.

Normal access is:

The 8-second interface appears because of a random delay of 5-10 seconds.

And then there’s this random 500 exception.

The corresponding log is as follows:

Four,

ChaosMonkey can also integrate with Spinnaker, which is a broader use. I’ll write it later.