Tomcat – High CPU Breakdown
Determine the process id (PID) of the process that has high CPU load.
The culprit:
16397 tomcat 24 0 2809m 1.2g 26m S 197.4 14.8 112:28.42 java
Use top, ps or the java jps tool. I used jps here.
sudo -u tomcat jps -l |
Output:
16397 org.apache.catalina.startup.Bootstrap 8985 sun.tools.jps.Jps |
We then try to create a thread dump with the java jstack tool.
sudo jstack 16397 > stacktrace.dmp |
Output:
16397: Unable to open socket file: target process not responding or HotSpot VM not loaded The -F option can be used when the target process is not responding |
sudo jstack -F 16397 > stacktrace.dmp |
If that is also not working you can try quitting the process.
sudo -u tomcat kill -QUIT 16397 |
You will need to check the logs to see the stacktrace.
You can then check out the running threads and their state. I found that some threads were in a blocking state due to a few java.lang.OutOfMEmoryError errors.
To get more detailed information we can also use the jmap command to do a little deeper digging.
sudo jmap -dump:file=thread_dump.16379.dmp -F 16397 |
Categories: Linux