Friday, October 7, 2011

How to take thread dumps in JBOSS?

If you see any request is taking a lot of time, in order to know what might be the issue, you can go through thread dumps.  Thread may be waiting for some resource (it can be database call or any third party call), you can know exact cause by looking at thread dumps.

What is a thread dump?
   Current snapshot of threads which are running in JVM.

By using jboss jmx-console
http://localhost:8080/jmx-console
and search "serverInfo" and click on that link
Click invoke under listThreaddump
Which will give you current snapshot of threads which are running in JVM.

By using twiddle
go to <JBOSS-HOME>/bin
In windows - 
twiddle.bat invoke "jboss.system:type=ServerInfo" listThreadDump > dump.html
dump.html will have your thread dump.

In unix-based machines
/jboss/bin/twiddle.sh invoke "jboss.system:type=ServerInfo" listThreadDump > dump.html 2>&1
Using "Interrupt" signal - SIGQUIT
Use kill -3 <process-id> to generate thread dump. You will find the thread dumps in server logs.

Typically to know exact cause you need to take at least 2 to 3 thread dumps with 30 seconds gap, so that you will know what is the common thread which is waiting for long time.


3 comments:

  1. Methods 1 and 2 are not available on JBoss AS 7. Do you have anothe solution than kill -3 to get a thread dump in that case ?

    ReplyDelete
    Replies
    1. Can you try methods mentioned here - http://atgkid.blogspot.com/2011/12/how-to-take-thread-dumps-and-heap-dumps.html

      Delete
  2. For 10.2, you can use /atg/dynamo/service/ThreadDumpService on dyn/admin to get thread dumps on debug log, provided the performance of your instance is accepting a new HTTP session

    - Dhaya

    ReplyDelete