Quantcast
Channel: BI Platform
Viewing all articles
Browse latest Browse all 317

Using JVMTOP and JVMMON to analyze Tomcat CPU bottlenecks

$
0
0

tomcat77.png

 

Troubleshooting CPU bottlenecks on the Apache Tomcat application server can be challenging.  Since Apache Tomcat is running as a Java Virtual Machine, understanding which JVM threads are consuming the overall Tomcat CPU can be a bit of a black box since this information is not easily accessible in regular monitoring tools.  Recently, I have discovered a brilliant new tool called JVMTOP which provides direct insight into the performance of threads running on a Java Virtual Machine.  Additionally, JVMTOP also shows in real-time which threads are blocked and also the id of the thread it is currently waiting on.  In this article, I will provide a demonstration on how this tool works and what information you need to collect once you have identified the problematic Java thread(s) so that SAP can perform a deeper root cause analysis.

 

Identify the CPU bound thread using JVMTOP


I have made a slight modification to the JVMTOP application (updated the exectuable jar manifest for ease of use) and created a new batch file to launch the application.  Download the version linked from this article when following this tutorial.  Note, this tutorial was tested only against Apache Tomcat running SAPJVM


  1. Download jvmtop.zip

  2. Extract the files from jvmtop.zip to <INSTALL_DIR>\SAP BusinessObjects Enterprise XI 4.0\win64_x64\sapjvm\bin on your Apache Tomcat node

  3. Open a command prompt and browse to <INSTALL_DIR>\SAP BusinessObjects Enterprise XI 4.0\win64_x64\sapjvm\bin
  4. Open task manager, click view --> select columns, select PID (Process Identifier) and determine the process id of tomcat.exe

    tomcatt1-1.png

  5. In the command prompt, execute the command: runJVMTOP.bat <PID>.  For example:

    tomcatt3.png

  6. JVMTOP will connect to the SAPJVM and list the top 10 Java threads which are consuming the most CPU.  Notice, it will continue to stay connected and the values are refreshed automatically in real-time similar to the Unix version of toptomcatt5.png

    COLUMNDESCRIPTION
    TIDJVM thread ID
    NAMEName of JVM thread
    STATEThe state that the thread is currently in
    CPUCurrent CPU utilization (in ratio to available cpu time on all processors)
    TOTALCPUCPU utilization (in ratio to process cpu consumption) since the thread is alive
    BLOCKEDBYIf this thread is blocked, this column shows the thread id which is blocking this thread

  7. In the above example, we can easily identify that the thread creating the CPU bottleneck is http-8080-5 with thread id 48


Create thread dumps using JVMMON

Now that we have identified the offending thread, we need to generate a thread dump so that we can analyze the call stack of the code currently being executed by this thread.  SAPJVM includes a utility called JVMMON which makes creating thread dumps very easy to do without a lot of additional configuration.


  1. Open a command prompt and browse to <INSTALL_DIR>\SAP BusinessObjects Enterprise XI 4.0\win64_x64\sapjvm\bin
  2. Execute the file jvmmon.exe and it will print out a list of running JVM processes and their corresponding process id (PID)
  3. Enter the process id of the Apache Tomcat Server JVM and press enter

    tomcat7.png

  4. Enter the command “print to file” and when prompted for “file=” enter a path and file name for the first thread dump. NOTE: You must first create the folder structure where you intend to save the file.

  5. Next, enter the command "print stacktrace" and at the same time, take a screenshot of the current JVMTOP output. 

    tomcat10.png

    The threads shown in JVMTOP will match the thread details shown in the thread dump and then deeper root cause analysis can be performed by SAP

    tomcat12.png

  6. Repeat the thread dump / JVMTOP screenshot collection while the CPU is bottlenecked (at an interval of five minutes between each collection).  The more iterations of this information that is collected, the easier it will be to diagnose the bottleneck

  7. Exit JVMTOP by typing CTRL-C and choose (Y) to end the batch job.  Use the command exit to exit from JVMMON

       tomcat13.png

 


For more information about JVMTOP, you can visit the homepage at:

 

 

 

Documentation - jvmtop - Java monitoring for the command-line - Google Project Hosting

 

 

 

 

 

 




Viewing all articles
Browse latest Browse all 317

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>