• /
  • EnglishEspañol日本語한국어Português
  • Log inStart now

Real-time profiling for Java using JFR metrics

With New Relic's real-time profiling for Java using Java Flight Recorder (JFR) metrics, you can run continuous, always-on profiling of your Java code in production environments. The accompanying JVM cluster timeline view provides a fast and intuitive way to diagnose cluster-wide performance problems. For example, you can quickly see how an application’s deployment affects the overall health of the cluster.

Find performance bottlenecks

Troubleshooting performance bottlenecks in your Java application or service can help you better understand the following:

  • Where you’re wasting resources
  • When an incident occurs
  • What happened during an incident
  • What performance issues led up to an incident

To make troubleshooting faster and easier, you need to see the high fidelity runtime characteristics of your code running on the JVM, and you need that data in real time.

JFR daemon

The JFR daemon is an exporter for JFR events which allows you to harness the power of the New Relic platform for visualizing your JVM's behavior. Using the New Relic Java telemetry SDK as the underlying implementation, the JFR daemon converts JFR events into New Relic telemetry types and reports them to New Relic's metric and event ingest APIs.

There are three different usage scenarios for the JFR daemon:

  • New Relic Java agent JFR service (RECOMMENDED) - JFR monitoring built into the flagship New Relic Java agent. No additional setup is needed, simply install the Java agent, make sure that the JFR service is enabled, and JFR data will flow into the same application as the Java agent. Requires New Relic Java agent version 7.0.0+.
    • Note: JFR realtime profiling can be toggled via agent server side configuration. This allows profiling to toggled without the need to restart the target application.
  • Standalone process - Run the jfr-daemon as a standalone process and configure it to monitor an existing Java process using remote JMX.
  • Standalone Java agent - Attach the jfr-daemon to your Java process as a Java agent. A lightweight alternative to the New Relic Java agent.

Supported Java versions

While the JFR daemon supports any version of Java 11 and above, we don't recommend using any non-LTS version of Java in production environments.

Some vendors have backported JFR to their Java 8 binaries. For instance, OpenJDK backported JFR on version 8u262. The JFR daemon is compatible with those Java versions.

Requirements and Usage Instructions

Requirements and instructions vary for each usage scenario. For full details please see the links for your specific usage scenario:

Important

Apps running with the JFR daemon should expect the JFR subsystem to use additional memory.

Tip

With Java agent release 8.0.0 or above, you can dynamically change your JFR profiling configuration without restarting your JVMs. Do this by toggling the setting in Settings > Application > Java Flight Recorder or by changing the jfr.enabled configuration.

View your data

To view your data, go to one.newrelic.com > All capabilities > APM & Services > (select service) > More views > Realtime Profiling Java.

Understand JVM cluster behavior over time

The JVM cluster timeline view shows the JVM behavior across your entire cluster. This timeline enables quicker troubleshooting and issue detection; for example, at a glance you can see:

  • How a recent deployment affected the rest of the JVM cluster
  • When a JVM restarted
  • How an individual instance was affected by its noisy neighbor

To make troubleshooting easier, you need to see the high fidelity runtime characteristics of your code running on the JVM, and you need that data in real time.

New Relic Java Flight Recorder (JFR) UI

one.newrelic.com > All capabilities > APM & Services > (select service) > Realtime Profiling Java: The JVM cluster timeline view shows the JVM behavior across the cluster.

Each row of the timeline represents a specific JVM over time. Inside each row, a box represents a 5-minute period of that JVM's life. From least severe to most severe, yellow, orange, and red traffic lights indicate anomalous behavior for a JVM, so you can drill down into that instance and the right time period when investigating errors or other performance issues.

How JVM health is measured

Select How is JVM health determined? for a detailed breakdown of how JVM health is calculated.

JVM details

To find the JVM details page, go to: one.newrelic.com > All capabilities > APM & Services > (select service) > Realtime Profiling Java > (select JVM).

The details panel for each JVM provides several critical views:

  • User CPU Usage Percentage
  • Machine CPU Usage Percentage
  • Heap Sizes
  • Garbage Collection Duration
  • Longest Garbage Collection Pause
  • User Thread CPU Utilization
  • System Thread CPU Utilization
  • Small Object Allocation per Thread
  • Large Object Allocation per Thread
  • Network Read per Thread
  • Network Write per Thread
  • Buffer Allocation Size per Thread
  • Total Thread Allocation
  • Total Object Allocation per Thread
  • Metaspace

Identify resource-intensive code paths with flame graphs

Important

The flame graph feature is only compatible with the New Relic Java agent JFR service usage scenario.

A "flame graph" is a way of visualizing the call tree. Each block in the graph represents a function. The more CPU time and memory resources a method consumes, the wider that block is.

Use flame graphs to identify the Java classes and methods that are most frequently executed in your application code. By using flame graphs to optimize the hot spots in your code, you can reduce resource consumption and increase your application’s overall performance.

Here are some details about the flame graph colors:

  • Gray gradient: We apply the gray gradient to methods from a Java SE package. Lower call counts have lighter shades, gradually transitioning to darker ones as the call count increases.
  • Yellow-orange gradient: We apply the yellow-orange gradient to methods from other libraries. Lower call counts have more yellow colors, gradually transitioning to more orange colors as the call count increases.
Screenshot of New Relic Java flame graph.

one.newrelic.com > APM & Services > (select service) > Realtime Profiling Java > (select JVM): You can see details for each JVM, including flame graphs.

Copyright © 2024 New Relic Inc.

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.