JVisualVM is a powerful tool that provides a visual interface to see deep and detailed information about local and remote Java applications while they are running on a Java Virtual Machine (JVM).
jVisualVM is used to track memory leaks, analyze the heap data, monitor the garbage collector and CPU profiling. It also helps to improve the application performance and ensure that memory usage is optimized. With features like thread analysis and head dump analysis, it is very handy in solving run-time problems.
VisualVM is free, and you don’t need to pay a separate cost to get this.
In this blog, we are going to look how jVisualVM can be used to monitor the performance of DWP/Smart IT Tomcat.
Recommendation on Java Heap Space.
To remotely monitor the health of tomcat, please add below parameters in tomcat
You can add above settings as below
Windows: C:\Program Files\Apache Software Foundation\Tomcat7.0\bin\SmartITMyITTomcat8w
File Name: /opt/apache/tomcat8.5/bin/setenv.sh
CATALINA_OPTS="-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=8086 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false -Djava.rmi.server.hostname=DWP/SmartITServerName"
Make sure you have JDK installed on one of your client workstation or on your laptop. JVisualVM is available with JDK.
Open Tool > Plugins
To connect to your SmartIT/DWP tomcat instance:
Click remote > Add remote host
Enter MyIT/SmartIT Tomcat Server details
Once you connected, you can see the Heap Chart showing the Max Heap Space. You can monitor this chart during peak load. In the event, you see an issue like unable to login to application, application performing very slow, click on the heap dump available in the chart that you can share with BMC to identify what is consumed within the tomcat heap during runtime. This heap dump is crucial to find the root cause analysis of performance or application login issue.
There is also a chart for GC which helps narrow down the memory leak issues. The last chart about Threads will help you narrow down whether the application maxed out the threads or not in the event of performance. You can get the thread dump along with heap dump to identify the busy threads.
Things to check:
Our Recommendation is to keep the Min and Max Heap should be same.
Windows: You can put the initial memory and Max memory pool by opening SmartITMyITTomcat8w within C:\Program Files\Apache Software Foundation\Tomcat7.0\bin folder.
Unix: You can put this in setenv.sh and pass as one of the JAVA_OPTS or just append to above parameter where we define the remote monitoring within setenv.sh
If you install VisualVM- MBeans Plugin, you can review the values set for the tomcat
For Example: MaxThread parameter set to 500 threads for http connector
There are many important features that VisualVM supports, such as:
1. Visual interface for local and remote java applications running on JVM.
2. Monitoring of application’s memory usage and application’s runtime behavior.
3. Monitoring of application threads.
4. Analyzing the memory allocations to different applications.
5. Thread dumps – very handy in case of deadlocks and race conditions.
6. Heap dumps – very handy in analyzing the heap memory allocation.
I hope you find this blog useful. Please comment on this blog with your suggestions to make the blog more productive and appreciate your general comments as well on this blog.