This post describes how to profile a Spring Boot web application with JConsole(the default profiling tool provided by JDK).
- Start the Spring Boot web application with JMX enabled(from here).
1 | # Start the Spring Boot web application. This command will enable the JMX service on port 6001. |
Notes:
a. With the “-D” arguments, the web application enables the JMX service on port 6001.
b. You need to incidate the current server’s IP in the “-Djava.rmi.server.hostname” argument.
- Open the port used by JMX in Firewall. If you server has firewall, you need this step. In my case, it’s a CentOS with the “firewall-cmd”.
1 | sudo firewall-cmd --zone=public --add-port=6001/tcp --permanent |
- Use JConsole to connect.
Open JConsole, enter “10.80.20.119:6001” to connect the RMI port.
Now it everything works, you can see the profiling result charts in JConsole(memory, CPU, classes, threads & etc).