Introduction to JDK Flight Recorder
JDK Flight Recorder, JFR, is an observability and monitoring framework built into the HotSpot JVM that can be used for debugging and profiling applications. JFR allows users to debug and profile their applications helping to find intermittent or difficult-to-spot bugs, performance improvements, and more. This series will walk you through the key features, APIs, and concepts of the JDK Flight Recorder.
Key Features of JDK Flight Recorder
Like the board game Go, JFR can be relatively easy to pick up, able to be enabled with a single JVM argument -XX:StartFlightRecording
, but also like Go, difficult to master. This section will help familiarize new, and even experienced, users of JFR with some of the key features and terminology to help provide context for the rest of this series.
Built into the HotSpot JVM
As mentioned in the intro, JFR is built directly into the HotSpot JVM. All applications running on the HotSpot JVM, or a HotSpot derivative JVM, will have access to JFR without any configuration steps or needing to download a separate binary or library. This greatly lowers the barrier of entry for using JFR as extensive security reviews or product evaulations are not necessary.
Free to Use in Production
For users running JDK 11 or later, JFR can be used in production without a commercial license. This change was part of the process of open-sourcing JFR and contributing it to the community as covered in JEP 328: Flight Recorder. Also with this change JFR was renamed from Java Flight Recorder, to JDK Flight Recorder. So while using "Java Flight Recorder" would be an out of date reference, it is referring to the same technology.
Low Overhead and Always-On Capability
JFR takes its name from an airplane flight recorder. And like an airplane flight recorder, JFR has low-overhead of ~1% with default settings, and should remain under 2% with profile settings. Allowing it to be used in production without concern that it will negatively impact an application performance. JFR is also capable of being always-on. JFR will write captured contents to temporary files, or only store them in-memory, and as configurable data retention limit are reached, overwrite the oldest content.
Event-Based Observability and Monitoring Framework
The data JFR collects are called events. Events are self-describing elements of data that are propagated from the execution of code in the JVM and applications running on the JVM. Users are able to configure how JFR collects events, and even define their own events for collecting additional data about thier applications.
Last update: September 14, 2021