Friday, November 27, 2015

WebLogic JDBC performance analyzing using Java Flight Recorder

Java Flight Recorder (JFR) is a tool for monitoring Java applications. JFR is integrated into Java Virtual Machine (JVM). It have less than 1% overhead and is capable for monitoring production systems without affecting performance.

To enable JFR with the JVM that will run a WebLogic server we need to start the WebLogic using 2 flags:

-XX:+UnlockCommercialFeatures
-XX:+FlightRecorder

The JVM default JMX port is 7091. We can change it and set it for example to 7093 using:

-Dcom.sun.management.jmxremote.port=7093

This is useful when monitoring multiple managed servers on the same machine. Each managed server can have it's own port.

For development servers we can also disable authentication and SSL using the following (this is an insecure setting, do not use it with production machines):

-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.ssl=false

We can then open the Java Mission control using the jmc command from JAVA_HOME bin folder

$ cd $JAVA_HOME/bin
$ ./jmc

Java Flight Recorder have an "experimental" plugin for WebLogic. Its there a long time and it looks very stable. Installation is from the help | Install New Software... menu of Java Mission Control. Plugin is under Flight Recorder Plugins and called "WebLogic Tab Pack"


Then we can start recording events on our weblogic server. We can do that using Java Mission Control. Go to menu File | Connect and then "Create a new connection". If we have disable authentication and SSL we only need to put hostname and port for our server. After there is a selection for open a JMX console to live monitoring the server or "Start Flight Recording". We select to start the recording and in the final screen we can select the duration of the recording. There is an option to start a continuous recording too, which if we select it, starts a recording that will never stops and contains events for the size or age we configure. We can dump and analyze this continuous recording using Java Mission Control in a later time.

We can also start the recording on server using the jcmd from the JAVA_HOME/bin folder on server.

$ jcmd <java_process_id> JFR.start name=my_recording filename=myrecording.jfr dumponexit=true

You can find the managed server process with the following command replacing <managed_server_name> with our server name:

$ ps aux | grep <managed_server_name> | grep -v grep | awk '{print $2}'

After the recording is finished you can open the file using Java Mission Control.

You can view the JDBC performance metrics per SQL in the WebLogic -> Database Tab.


From that screen you can view the SQL commands with an average duration and Sample Count number. From that 2 metrics you may find bad performing SQL's or SQL's that are executing more times than expected or other problematic use cases.

Except from JDBC SQL performance data, that i highlight in this post, you can use Java Flight Recorder to view useful information and data about CPU usage, Memory, I/O, threads, Java Heap and a lot more.

You can read more about Java Mission Control and Java Flight Recorder here:

http://docs.oracle.com/javacomponents/jmc-5-5/jfr-runtime-guide/index.html

http://docs.oracle.com/javacomponents/jmc-5-5/jmc-user-guide/index.html

http://www.oracle.com/us/technologies/java/java-se-advanced-article-2370493.pdf?ssSourceSiteId=otnen

http://www.oracle.com/us/technologies/java/jm-java-mission-control-article-2255284.pdf?ssSourceSiteId=otnen

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.