Jun 21 2015

Using Java Mission Control And Flight Recorder

Posted by Mike Brunt at 4:44 PM Web Servers | CloudComputing | Performance | Caching | Java-JVM | ColdFusion | JRun-J2EE

This weekend I finally got around to spending a lot of time on the great features which were added to the Oracle Hotspot JVM with version 7u40, with regard to monitoring and tuning the JVM.  This was the addition of Java Mission Control and Flight Recorder which are truly mighty tools which I recommend to anyone interested in the operation and performance of the Java Virtual Machine (JVM), to check out.  I had actually tried to get this up and running a few weeks ago without success, it seems there were a few steps I was missing and thanks to this great Stack Overflow question and answer, I found the steps needed.  I am also posting the steps below in this blog piece, in case that article ever gets moved or removed as the steps are key to getting this working.

There is a lot to blog about in these tools and rather than repeat what is already out there, here is a good Oracle tutorial on installing and using the tools. 

I will share something very pleasing and reaffirming which came out of 3 years looking at Java on 64-bit which did not go well at first for Java.  During those 3 years I have gradually evolved a set of very beneficial JVM arguments which seem to truly get the best results from Java on 64-bit web environments.  After 20 hours and load tests which generated 131 thousand requests and half a million queries, just over 4 seconds were spent in garbage collections, that the Old-Tenured Generation use never topped 400MB out of 1.6GB and that the Young-New Generation is behaving very efficiently, hence the Old Generation only being just over 24% used up.

Here are the steps and settings needed to get Java Mission Control and Flight Recorder running with ColdFusion on Tomcat (CF10 and CF11 - so if you are on CF11 just substitute that below).

"Adjust your jvm.config

a. Make a .bak copy of C:\ColdFusion1x\cfusion\bin\jvm.config

b. Add the following lines to the jvm.config




-Dcom.sun.management.jdp.name=ColdFusion10 (or CF11)




Open C:\program files\java\jdk1.8_**\lib\missioncontrol\configuration\org.eclipse.equinox.simpleconfigurator\bundles.info file with administrator privileges and remove the four lines that start with the following text (if there):





Edit the C:\program files\java\jdk1.8_xx\lib\missioncontrol\configuration\config.ini, and add the following line: eclipse.home.location=$osgi.install.area$

Start up : C:\program files\java\jdk_1.8.0_**\bin\jmc Note that JMC is launching from 1.8 while your ColdFusion instance is running with whatever the latest Hotspot version you have installed with your ColdFusion updater.

You can install plugins from the help -> install new software. The plugins site should already be there. This will give you full on memory analysis of a heap dump. It's not nearly as good as the JRockit memory analyzer, but it's better than nothing.

If you are running ColdFusion as a Windows service, you will need to open services.msc and shutdown your ColdFusion Application Server. Then open C:\ColdFusion10\cfusion\bin\cfstart.bat to fire up Tomcat and ColdFusion as a foreground application. The jOverflow plugin will not work when running as a windows service.

You will see your JVM appear in Java Mission Control, mine is call -Xdebug since I guess it has no name and starts with the first option.

Right click on your ColdFusion JVM and select "Start JMX console". You will see something that looks like this show up on the right:

Image capture of Java Mission Control


There is a whole lot to explore, including a lot of junk when it comes to examining memory due to having to sift through the ColdFusion Framework itself, but there are a ton of tutorials for deciphering what it means. This video is your primary introduction: https://www.youtube.com/watch?v=WMEpRUgp9Y4"