Skip to content

jonatan-ivanov/resourceater

Repository files navigation

Build Status

resourceater

Resourceater is a Java based web service which consumes your resources on demand. It can be useful to simulate high resource needs. It can consume the following resources:

  • Heap by creating byte arrays (this also simulates memory leaks)
  • Off-Heap by allocating direct byte buffers
  • CPU by spinning up threads which can make the cores busy
  • Disk by creating big files
  • Threads by creating simple daemon threads which are doing nothing
  • Servlet Container Threads by calling itself and blocking the Container's (Tomcat) thread
  • Classes by generating new classes and loading them on-the-fly
  • Network by downloading large files over HTTP
  • Sockets by creating server sockets

Endpoints

Check ReDoc or the Swagger-UI

Examples

Heap

curl -s -X POST "http://localhost:8080/resources/objects" -H "Content-Type: application/json" -d "{ \"size\": \"1MB\"}"

Off-Heap

curl -s -X POST "http://localhost:8080/resources/directBuffers" -H "Content-Type: application/json" -d "{ \"size\": \"1MB\"}"

CPU

curl -s -X POST "http://localhost:8080/resources/cores" -H "Content-Type: application/json" -d "{ \"size\": 1}"

Disk

curl -s -X POST "http://localhost:8080/resources/files" -H "Content-Type: application/json" -d "{ \"size\": \"1MB\"}"

Threads

curl -s -X POST "http://localhost:8080/resources/threadPools" -H "Content-Type: application/json" -d "{ \"size\": 1}"

Container Threads

curl -s -X POST "http://localhost:8080/resources/containerThreads" -H "Content-Type: application/json" -d "{ \"size\": 1}"

Classes

curl -s -X POST "http://localhost:8080/resources/classPools" -H "Content-Type: application/json" -d "{ \"size\": 1}"

Network

curl -s -X POST "http://localhost:8080/resources/httpClients"

Sockets

curl -s -X POST "http://localhost:8080/resources/socketPools" -H "Content-Type: application/json" -d "{ \"size\": 1}"

Monitoring

The project is using micrometer and it also opens JMX on port 8686; they give you a lot of information about what is going on under the hood, e.g.:

Docker

docker run -it -p 8080:8080 -p 8686:8686 -v logs:/app/logs jonatanivanov/resourceater:tag

Kubernetes

You need a cluster first, e.g.: kind create cluster

skaffold dev --port-forward

or

skaffold run --port-forward