The Java Flight Recorder (JFR) is a commercial feature. You can use it for free on developer desktops/laptops, and for evaluation purposes in test, development, and production environments. However, to enable JFR on a production server, you need a commercial license. Using JMC UI for other purposes on the JDK does not require a commercial license.
For more details about JFR commercial features and availability, see the product documentation.
For more details about JFR commercial license, see the license agreement.
The Java Flight Recorder records detailed information about the java runtime and the Java application running in the java runtime. The recording process is done with little overhead. The data is recorded as time stamped data points called events. Typical events can be threads waiting for locks, garbage collections, periodic CPU usage data, etc.
When creating a flight recording, you select which events should be saved. This is called a recording template. Some templates only save very basic events and have virtually no impact on performance. Other templates may come with slight performance overhead, and may also trigger GCs in order to gather additional information. In general, it is rare to see more than a few percentage of overhead.
Flight Recordings can be used to debug a wide range of issues from performance problems to memory leaks or heavy lock contention.
The following topic describes types of recording to produce a Java flight recording.
The following are two types of flight recordings - continuous recordings and profiling recordings.
Continuous Recordings: A continuous recording is a recording that is always on and saves, for example, the last six hours of data. If your application runs into any issues, you can dump the data from, for example, the last hour and see what happened at the time of the problem.
The default setting for a continuous recordings is to use a recording profile with extremely low overhead. This profile will not get heap statistics or allocation profiling, but will still gather a lot of useful data.
A continuous recording is great to always have running, and is very helpful when debugging issues that happen very rarely. The recording can be dumped manually using either jcmd or JMC. You can also set a trigger in JMC to dump the flight recording when some specific criteria is fulfilled.
Profiling Recordings: A profiling recording is a recording that is turned on, runs for a set amount of time, and then stops. Usually, a profiling recording has more events enabled and may have a slightly bigger performance impact. The events that are turned on can be modified depending on your use of profiling recording.
Typical use cases for profiling recordings are as follows:
Profile what methods are run the most and where most objects are created.
Look for classes that use more and more heap indicating a memory leak.
Look for bottle necks due to synchronization and many more such use cases.
A profiling recording will give a lot of information; even though, you are not troubleshooting a specific issue. A profiling recording will give you a very good view of the application and can help you find any bottlenecks or areas in need of improvement.
Note: A typical overhead is only around 2%, so you can definitely run a profiling recording on your production environment (which is one of the main use cases for JFR), unless you are extremely sensitive for performance or latencies. |