Java In Production : some useful tools for profiling and diagnostic.

This article has been written as “basic knowledge” for Junior Java developers to help them tracking their bugs in Java software.

Damn another list

I don’t have the ambition for this article to draw a global picture for all available in the JEE Ecosystem. No at all, it’s a basic highly subjective list of my favorite tools when I have to deal with Java performance or Java applications in production.

List the Java processes

OK, on Unix, there are a LOT of commands to obtain the same result.

ps -edf | grep java

Output : 

$>ps -edf | grep java
uharcom 1751 1 99 15:14 pts/0 00:00:02 /usr/bin/java -Djava.util.logging.config.file=/data/uharcom/tomcat/conf/ -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djdk..ephemeralDHKeySize=2048 -Xms512m -Xmx8192m -XX:MaxPermSize=256m -Xms512m -Xmx8192m -XX:MaxPermSize=256m -Dignore.endorsed.dirs= -classpath /data/uharcom/tomcat/bin/bootstrap.jar:/data/uharcom/tomcat/bin/tomcat-juli.jar -Dcatalina.base=/data/uharcom/tomcat -Dcatalina.home=/data/uharcom/tomcat org.apache.catalina.startup.Bootstrap start

But do you know that the JDK offers something better ?


Output : 


Thread dumps

Is your slow ? What is really happening ?

One way to have a diagnostic, is to suspend temporarily the application to print where the execution is stopped.

The thread dump can be a result.

To obtain the thread dump, you can use the following command : jstack PID

jstack [-l] <pid>
(to connect to running process)
jstack -F [-m] [-l] <pid>
(to connect to a hung process)
jstack [-m] [-l] <executable> <core>
(to connect to a core file)
jstack [-m] [-l] [server_id@]<remote server IP or hostname>
(to connect to a remote debug server)

-F to force a thread dump. Use when jstack <pid> does not respond (process
is hung)
-m to print both java and native frames (mixed mode)
-l long listing. Prints additional information about locks
-h or -help to print this help message

Jstat is an useful tool to perform profiling on a running process.

Next to read  How I switched my blog from OVH to Google Container Engine

Official link :

Obtain the classloader statistics : jstat -class PID

Obtain the garbage collector statistics : jstat -gc PID


jvisualvm is a powerful tool to track an monitor several statistics of an Java application.

jvisualvm : monitor Java applications
jvisualvm : monitor Java applications
jvisualvm2 : monitor your Java applications
jvisualvm2 : monitor your Java applications

If you can start your application on your machine, or your IDE, this tool is really useful to check the CPU and the memory Usage and to generate CPU and memory profiling.

, Gatling, UI : Write your REST tests and executes stress tests

JMeter, Gatling and Soap UI are three tools every REST backend developers should know. They are easy to use, and allow you to write different kind of automated tests : non-regression tests, performance and stress tests, functional tests.

Gatling : Load and performance testing
Gatling : Load and performance
Apache Meter
Apache Meter
Soap UI
Soap UI

Bonus  : a nice curated list

Check the github page : :// for a nice curated list.