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
Check ReDoc or the Swagger-UI
curl -s -X POST "http://localhost:8080/resources/objects" -H "Content-Type: application/json" -d "{ \"size\": \"1MB\"}"
curl -s -X POST "http://localhost:8080/resources/directBuffers" -H "Content-Type: application/json" -d "{ \"size\": \"1MB\"}"
curl -s -X POST "http://localhost:8080/resources/cores" -H "Content-Type: application/json" -d "{ \"size\": 1}"
curl -s -X POST "http://localhost:8080/resources/files" -H "Content-Type: application/json" -d "{ \"size\": \"1MB\"}"
curl -s -X POST "http://localhost:8080/resources/threadPools" -H "Content-Type: application/json" -d "{ \"size\": 1}"
curl -s -X POST "http://localhost:8080/resources/containerThreads" -H "Content-Type: application/json" -d "{ \"size\": 1}"
curl -s -X POST "http://localhost:8080/resources/classPools" -H "Content-Type: application/json" -d "{ \"size\": 1}"
curl -s -X POST "http://localhost:8080/resources/httpClients"
curl -s -X POST "http://localhost:8080/resources/socketPools" -H "Content-Type: application/json" -d "{ \"size\": 1}"
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.:
-
Metrics endpoint: /actuator/metrics
-
Heap usage: /actuator/metrics/jvm.memory.used?tag=area:heap
-
Direct byte buffers (Off Heap): /actuator/metrics/jvm.buffer.memory.used?tag=id:direct
-
CPU usage: /actuator/metrics/process.cpu.usage
-
Number of CPU cores: /actuator/metrics/system.cpu.count
-
Daemon thread count: /actuator/metrics/jvm.threads.daemon
-
Loaded Classes: /actuator/metrics/jvm.classes.loaded
-
Container (Tomcat) Threads: /actuator/metrics/tomcat.threads.current
docker run -it -p 8080:8080 -p 8686:8686 -v logs:/app/logs jonatanivanov/resourceater:tag
You need a cluster first, e.g.: kind create cluster
skaffold dev --port-forward
or
skaffold run --port-forward