Chapter 1. Introduction to JDK Flight Recorder

JDK Flight Recorder (JFR) is a low overhead framework for monitoring and profiling Java applications. For more information, see JEP 328: Flight Recorder.

You can collect data from events originating within the JVM and the application code. Data is then written in memory. At first, to thread-local buffer and then promoted to fixed-size global ring buffer before being flushed to JFR files (*.jfr) on the disk. Other applications can consume these files for analysis. For example, the JDK Mission Control (JMC) tool.

1.1. JDK Flight Recorder (JFR) components

You can use JFR functionality to observe events that run inside a JVM, and then create recordings from data collected from these observed events.

The following list details key JFR functionality:

Recordings
You can manage system recordings. Each recording has a unique configuration. You can start or stop the recording, or save it to disk on demand.
Events

You can use events or custom events to trace your Java application’s data and metadata, and then save the data and metadata from either event type in a JFR file. You can use various tools, such as Java Mission Control (JMC),jcmd, and so on, to view and analyze information stored in a JFR file.

The Java Virtual Machine (JVM) has many pre-existing events that are continuously added. An API is available for users to inject custom events into their applications.

You can enable or disable any event when recording to minimize overhead by supplying event configurations. These configurations take the form of xml documents and are called JFR profiles (*.jfc). The Red Hat build of OpenJDK comes with the following two profiles for the most common set of use cases:

  • default: The default profile is a low-overhead configuration that is safe for continuous use in production environments. Typically, overhead is less than 1%.
  • profile: The profile profile is a low-overhead configuration that is ideal for profiling. Typically, overhead is less than 2%.

1.2. Benefits of using JDK Flight Recorder

Some of the key benefits of using JDK Flight Recorder (JFR) are:

  • JFR allows recording on a running JVM. It is ideal to use JFR in production environments where it is difficult to restart or rebuild the application.
  • JFR allows for the definition of custom events and metrics to monitor.
  • JFR is built into the JVM to achieve the minimum performance overhead (around 1%).
  • JFR uses coherent data modeling to provide better cross-referencing of events and filtering of data.
  • JFR allows for monitoring of third-party applications using APIs.
  • JFR helps in reducing the cost of ownership by:

    • Spending less time diagnosing.
    • Aiding in troubleshooting problems.
  • JFR reduces operating costs and business interruptions by:

    • Providing faster resolution time.
    • Identifying the performance issues which helps in improving system efficiency.