Spring Boot Buggy APIs – Simulate performance problems

The Spring Boot Buggy API offers a valuable platform to simulate various performance issues in your applications. By intentionally creating problems like DB connection leaks, memory leaks, CPU spikes, and more, you can assess your system’s resilience and evaluate the effectiveness of performance tools.

Performance Issue Simulator
Fig 1: SpringBoot Buggy API – Performance Issue Simulator


Buggy Api is a Spring Boot Restful application to simulates different performance problems like DB Connections Leak, Memory Leak, OutOfMemoryError, CPU spike, thread leak, StackOverflowError, deadlock, unresponsiveness, …

Using this application, you can simulate various performance problems in your environment. Here are a few use cases where Buggy App can be used: 

  1. You can configure and launch Buggy API to consume high memory on the same server where your application is running. You can study under this circumstance whether your application’s SLA (Service Level Agreement) is impacted.
  2. You can configure and launch Buggy API in a docker container to consume high CPU and see whether other containers on the same host are impacted or not.
  3. If you are building performance tools or monitoring tools, you can simulate various performance degradations using Buggy API and see whether your tools address those performance problems.

OpenSource

The SpringBoot API project is an open source under the Apache V2 licence.

How to run the Buggy API Application?

1. Make sure Java 8 or above version is installed on your machine

Download the application jar 

Download the latest SpringBoot Buggy Api from here.

Run the application

1. java -jar ycrash.springboot_buggy.api-1.0.0.jar

2. Open the application in the browser http://{your-host}:8090/swagger-ui.html to invoke the Java performance problems using UI

How to invoke the performance problems?

Option 1: Using Swagger User Interface

The performance problems can be invoked via the SWAGGER-UI such as the http://{your-hostname}:8090/swagger-html and can invoke each of the services through “Try It Out” options for each of the leak scenarios.

Option 2: Using RestFul tools such as the command line such as curl commands

Example:

curl -X GET http://{your-hostname}:8090/v1/invoke/blocked-state

The above example will invoke the blocked state thread.

How to invoke the performance problems?

1. OutOfMemoryError: Java heap space

 To generate ‘java.lang.OutOfMemoryError: Java heap space’ invoke then invoke the following endpoint:

curl -X GET "http://{your-hostname}:8090/v1/invoke/oom-crash

2. Memory Leak

 If you would like to simulate a memory leak without experiencing OutOfMemoryError, then invoke the following endpoint:

curl -X GET "http://{your-hostname}:8090/v1/invoke/memory-leak

 When you launch the Buggy App with these arguments, 80% – 90% of the allocated memory will be consumed. But it will not result in OutOfMemoryError.

3. CPU spike

If you would like the CPU consumption to go up to 80 – 90%, then invoke the following endpoint:

curl -X GET "http://{your-hostname}:8090/v1/invoke/cpu-spike

4. Thread Leak

 If you would like the application to keep slowly spawning new threads, then invoke the following endpoint:

curl -X GET "http://{your-hostname}:8090/v1/invoke/thread-leak 

When you launch the Buggy App with these arguments eventually  ‘java.lang.OutOfMemoryError: Unable to create new native thread’ will be generated.

5. Deadlock

 If you would like the application to experience Deadlock, then invoke the following endpoint:

 curl -X GET "http://{your-hostname}:8090/v1/invoke/deadlock

6. Stackoverflow Error

 If you would like the application to experience ‘java.lang.StackOverflowError’, hen invoke the following endpoint:

  curl -X GET "http://{your-hostname}:8090/v1/invoke/stack-overflow

7. Blocked Threads

 If you would like to put multiple threads in BLOCKED state, then invoke the following endpoint:

 curl -X GET http://{your-hostname}:8090/v1/invoke/blocked-state

8. MetaSpace Leak

 If you would like to put multiple threads in BLOCKED state, then invoke the following endpoint:

 curl -X GET http://{your-hostname}:8090/v1/invoke/meta-space-leak

9. DB Connection Leak

 If you would like to simulate the DB connections leak problem, then invoke the following endpoint:

curl -X GET http://{your-hostname}:8090/v1/invoke/db-connections-leak?datasource.url={datasource.url}&datasource.username={datasource.username}&datasource.password={datasource.password}&&datasource.tablename={datasource.tablename}

Note: DB connection URL, username, password and table name need to be passed as part of the URL parameters.

10. File Connection Leak

 If you would like to simulate the file connections leak problem, then invoke the following endpoint:

curl -X GET http://{your-hostname}:8090/v1/invoke/db-connection-leak

Summation

In conclusion, the Spring Boot Buggy API serves as a practical tool for testing and addressing performance problems. Whether it’s identifying memory leaks or CPU spikes, this open-source application helps developers and system administrators proactively tackle performance challenges. By invoking these scenarios, you can gain insights into your system’s behavior and verify the efficacy of your monitoring and performance optimization strategies. This tool empowers you to create a more robust and resilient software environment.

Leave a Reply

Powered by WordPress.com.

Up ↑

%d