Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tools to monitor java thread execution

I've a java web application running on an Tomcat server(Linux). In the production environment I'm facing some performance issue. At random intervals the jsvc process on which tomcat is running starts to run at 90-100% CPU. I'm unable to find out the trigger for this event. The server is a quad core system. Memory consumption does not indicate any abnormalities.

How can I monitor which thread(application stack trace) in the application is causing the problem?

I'm checking with jconsole and PSI Probe, but both are not giving any detailed information about what thread inside the application is causing the CPU usage abnormality.

like image 808
Arun P Johny Avatar asked Jan 14 '11 03:01

Arun P Johny


People also ask

How do I monitor JVM threads?

The simplest way to see the number of threads in Java is to use a graphical tool like Java VisualVM. Apart from the application threads, Java VisualVM also lists the GC or any other threads used by the application like JMX threads. Monitoring the number of threads is the most basic feature in Java VisualVM.

How do I monitor my thread status?

In order to monitor a thread's status Java have predefined currentThread. getName() method that is extended by Thread Class. The getName() method of java.

Which of the following is a Java monitoring tool?

SolarWinds AppOptics is a Java application performance monitoring tool that helps developers analyze Java-based applications down to the code level.


1 Answers

One relatively easy way to do this (which may or may not work for your case -- depends on how long the behavior occurs):

When your app exhibits the behavior you want to debug (in this case, 90-100% CPU use) use jstack on the process ID:

http://download.oracle.com/javase/6/docs/technotes/tools/share/jstack.html

to examine what threads are running and in what methods they occur. If you do that a few times, it may be relatively easy to spot the culprit call chain. You can then just debug the entrance to that chain.

It's not necessarily the best or most elegant method, but it's very easy to do and it may be all you need. I would start there. It's akin to the "printf is the best debugger I've ever used" philosophy.

like image 100
kvista Avatar answered Nov 14 '22 21:11

kvista