Upload
isuru-perera
View
731
Download
3
Embed Size (px)
Citation preview
Great tools in Java Development Kit
05 November 2014
Senior Software Engineer
M. Isuru Tharanga Chrishantha Perera
Using Java Mission Control & Java Flight Recorder
2
Agenda
๏ What is Java Mission Control (JMC)
๏ Java Flight Recorder (JFR)
๏ Using JMC
๏ Demos
What is Java Mission Control?
๏ A set of powerful tools running on the Oracle JDK to monitor and manage Java applications
๏ Less performance overhead
๏ Free for development use (Oracle Binary Code License)
๏ Available in JDK since Java 7 update 40
๏ Two main tools: JMX Console & JFR
๏ Supports Plugins
3
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.
4
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
5
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
๏ It’s like the “black box” used in aircraft
6
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
7
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
8
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
9
Starting Java Mission Control
๏ Run “jmc” command in $JAVA_HOME/bin
๏ It runs on Eclipse
๏ It can also be installed on your existing Eclipse
๏ If it 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'
10
JMC Overview
11
Enabling Java Flight Recorder
๏ The server VM needs to be started with following options
๏ -XX:+UnlockCommercialFeatures -XX:+FlightRecorder
๏ 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=d.jfr,settings=profile
๏ Use following to change log level
๏ -XX:FlightRecorderOptions=loglevel=info
๏ The command “jcmd” can also be used
12
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)
13
Start Flight Recording Wizard
14
Event Options for Profiling
15
Event Details for Profiling
16
Demo
๏ Enable JFR in WSO2 ESB
๏ Sample applications from Marcus Hirt’s Tutorials (http://hirt.se/blog/?p=611) to demonstrate:
๏ CPU Usage viewing in JMC
๏ How to view deadlocked threads in JMC
๏ Flight recording and observing Memory/Garbage Collections tab
17
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 HotSpotJVM
๏ JMC & JFR - Diagnostic Tools
18