Profiling Tomcat Remotely with Java Mission Control


I was interested to see why a tomcat app runs very slow. In the tooling stage, I picked Java Mission Control(jmc) because it’s a built-in of Oracle Java 8.

To enable jmc and its flight recorder, I added the following Java switches to tomcat’s setenv.h file:

CATALINA_OPTS="$CATALINA_OPTS -XX:+UnlockCommercialFeatures -XX:+FlightRecorder -Dcom.sun.management.jmxremote=true -Dcom.sun.management.jmxremote.rmi.port=7091 -Dcom.sun.management.jmxremote.port=7091 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false"

Having restarted tomcat, double check if the port is open:

netstat -tlnp |grep 7091

Then I can run jmc on my laptop and connect to the tomcat box’s port 7091(default remote jmx port). You need to ensure the port is open to your network though, eg. firewall rules or port forwarding via ssh.

🙂