Presentation slides used at the 17th Java Colombo Meetup.
http://www.meetup.com/java-colombo/events/218658123/
This presentation explains the JMX Console & Java Flight Recorder (JFR) tools in Java Mission Control (JMC)
6. What is Java Mission Control?
A set of powerful tools running on the Oracle JDK to
monitor and manage Java applications
Free for development use (Oracle Binary Code License)
Available in JDK since Java 7 update 40
Supports Plugins
Two main tools
JMX Console
Java Flight Recorder
04/12/2014Java Colombo Meetup
6
7. Starting Java Mission Control
Run “jmc” command in $JAVA_HOME/bin
It runs on Eclipse
It can also be installed on your existing Eclipse
04/12/2014Java Colombo Meetup
7
8. Troubleshooting Tip
If “jmc” crashes with SIGSEGV on Ubuntu, try following
sudo -E sh -c 'echo org.eclipse.swt.browser.DefaultType=mozilla >>
$JAVA_HOME/lib/missioncontrol/configuration/config.ini'
04/12/2014Java Colombo Meetup
8
9. Java Process Browser
Uses the Java Discovery Protocol (JDP).
Allows to list and connect to both locally and remotely running Java
applications.
JMC provides full secure access with encrypted communication and
configurable user access restrictions.
04/12/2014Java Colombo Meetup
9
10. JMX Console
A tool for monitoring and managing multiple Oracle JDK instances via JMX
interface
Captures and presents live data about:
Garbage Collection (GC) Pauses
Memory (Heap Usage)
CPU Usage
Other attributes exposes via MBeans
Provides triggers that can monitor MBeans and trigger an action
04/12/2014Java Colombo Meetup
10
12. JMX Console Tabs
Overview – Dashboard, Graphs with real-time usage statistics
System – Information about the JVM
Memory – Monitor heap usage, garbage collection & active memory
pools
Threads – Live thread usage by the application
MBean Browser – Access all registered MBeans
Triggers – Manage rules that trigger events
Diagnostic Commands – Execute commands on JVM
04/12/2014Java Colombo Meetup
12
13. JMX Console Demo
Sample applications from Marcus Hirt’s Tutorials
(http://hirt.se/blog/?p=611)
Demonstrating
CPU Usage viewing in JMC
View deadlocked threads
04/12/2014Java Colombo Meetup
13
Image Source: https://duke.kenai.com/boxer/boxer.gif
14. Flight Recorder
“Black box” used in aircraft
04/12/2014Java Colombo Meetup
14
Image Source: http://commons.wikimedia.org/wiki/File:Black_box.aeroplane.JPG
15. Java Flight Recorder
A profiling and event collection framework built into the Oracle JDK
Gather low level information about the JVM and application are behaving
without performance impact (less than 2%)
Always on Profiling in Production Environments
Engine was released with Java 7 update 4
04/12/2014Java Colombo Meetup
15
16. Data Collection
JFR stores data in a hierarchy of in-memory buffers.
The data is moved to the disk when the buffers are full
Initially the JFR stores data in thread-local buffers. (Improves throughput,
no synchronization for every event)
Once the thread-local buffer has been filled, the data is transferred to a
global buffer. (Requires synchronization)
After the buffers are full, the data is written to the disk
04/12/2014Java Colombo Meetup
16
17. Data Analysis
JFR Plugin in JMC provides dynamic and in-depth analysis of all collected
JFR data.
JFR enables users to analyze all aspects of a Java application
Can analyze the Code, Memory, Threads, Locks and I/O
04/12/2014Java Colombo Meetup
17
18. Type of Events in JFR
Instant events – Events with only one time
Requestable events – Events with a user configurable period
Duration events – Event with a start and end time
Timed events – Duration events with a user configurable threshold
04/12/2014Java Colombo Meetup
18
19. JFR Recoding Types
Time Fixed Recordings
Fixed duration
The recording will be opened automatically in JMC at the end(If the recording
was started by JMC)
Continuous Recordings
No end time
Must be explicitly dumped
04/12/2014Java Colombo Meetup
19
20. Enabling Java Flight Recorder
The server VM needs to be started with following options
-XX:+UnlockCommercialFeatures -XX:+FlightRecorder
Make sure to use JDK 7u40 or later
For remote monitoring, start with appropriate com.sun.management flags
04/12/2014Java Colombo Meetup
20
21. Flight Recording from JMC
Right click on JVM and select “Start Flight Recording”
Select the type of recording: Time fixed / Continuous
Select the flight recording template
Modify the event options for the selected flight recording template
(Optional)
Modify the event details (Optional)
04/12/2014Java Colombo Meetup
21
25. Flight Recording using startup flags
To produce a Flight Recording from the command line, you can use “-
XX:StartFlightRecording” option. For example
-
XX:StartFlightRecording=delay=20s,duration=60s,name=Test,filename=recording.
jfr,settings=profile
Setting are in $JAVA_HOME/jre/lib/jfr
Use following to change log level
-XX:FlightRecorderOptions=loglevel=info
04/12/2014Java Colombo Meetup
25
26. The Default Recording
Use default recording option to start a continuous recording
-XX:FlightRecorderOptions=defaultrecording=true
Default recording can be dumped on exit
Only the default recording can be used with the dumponexit and
dumponexitpath parameters
-
XX:FlightRecorderOptions=defaultrecording=true,dumponexit=true,dumponexit
path=/tmp/dumponexit.jfr
04/12/2014Java Colombo Meetup
26
27. Creating Recording with “jcmd”
command
The command “jcmd” can also be used to start flight recording
Start Recording Example:
jcmd <pid> JFR.start delay=20s duration=60s name=MyRecording
filename=/tmp/recording.jfr settings=profile
Check recording
jcmd <pid> JFR.check
Dump Recording
jcmd <pid> JFR.dump filename=/tmp/dump.jfr name=MyRecording
04/12/2014Java Colombo Meetup
27
28. Analyzing Flight Recordings
JFR runtime engine dumps recorded data to files with *.jfr extension
These binary files can be viewed from JMC client
There are tab groups showing certain aspects of the JVM and the Java
application runtime such as Memory, Threads, I/O etc.
04/12/2014Java Colombo Meetup
28
30. JFR Tab Groups
General – Details of the JVM, the system, and the recording.
Memory - Information about memory & garbage collection.
Code - Information about methods, exceptions, compilations, and class
loading.
Threads - Information about threads and locks.
I/O: Information about file and socket I/O.
System: Information about environment
Events: Information about the event types in the recording
04/12/2014Java Colombo Meetup
30
31. Operative Set
A global set of events
Events can be added or removed from the context menu
A check box is used to show events in the operative set
04/12/2014Java Colombo Meetup
31
33. References
Java Mission Control
Marcus Hirt’s Blog
Advanced Java Diagnostics and Monitoring Without Performance
Overhead - Oracle Whitepaper
Oracle Java SE Advanced
InfoQ - Mission Control and Flight Recorder on HotSpot JVM
JMC & JFR - Diagnostic Tools
JDK Development Tools
Java Mission Control and Flight Recorder Demo Series
04/12/2014Java Colombo Meetup
33