Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I figure out what threads are utilizing a lot of CPU on Wildfly 11 using the CLI tool?

I'm using Wildfly 11 with Java 8 on Amazon Linux. How do I use the Wildfly CLI tool to monitor thread usage? We have high CPU utilization on our app servers and I'm trying to figure out what the problematic theads and operations are. We do not have "jconsole" installed on our servers or maybe this article would have been helpful -- http://www.mastertheboss.com/jboss-server/jboss-monitoring/how-to-monitor-jboss-cpu-usage .

Specifically, I'm wondering what the name of the Wildfly subsystem that I have to type into the CLI tool would be that would reveal the long running/high CPU usage threads.

like image 955
Dave Avatar asked Sep 06 '18 19:09

Dave


2 Answers

I would use Java Mission Control and it's flight recording function. You will need to take a copy of jconsole.bat or jconsole.sh and edit to run jmc with the classpath defined. You then use the same custom jmx url as for jconsole

like image 167
Will T Avatar answered Oct 20 '22 01:10

Will T


To findout which thread is consuming more CPU you have to collect CPU usage(in RHEL using top command(top -b -n 1 -H -p JBoss_PID)) and thread dump at the same time stamp when you face issue. From the top command output, you can identify process ID's for java threads utilizing a large percentage of the CPU. For example, output top command shows CPU being used by three Java threads:

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
  4382 root      25   0 1284m 480m  80m R 39.5 23.7  13:00.64 java
  6657 root      25   0 1284m 480m  80m R 39.5 23.7   7:23.10 java
  16322 root      25   0 1284m 480m  80m R 19.8 23.7  57:51.77 java

Using the Thread Dump Analyzer (TDA) tool, you can load the thread dumps that were gathered with the CPU data. Click on the Native-ID column in the upper right pane to sort by native thread ID and cross reference the light weight thread IDs from the top output to see the threads consuming high CPU.

like image 27
Abhijit Humbe Avatar answered Oct 20 '22 01:10

Abhijit Humbe