Troubleshooting high CPU usage in Java environments

Using FusionReactor APM to identify deadlock conditions in your Java applications
How to troubleshoot slow running requests in microservices

How to troubleshoot high CPU usage

In this scenario, our CPU is spinning at an abnormally high rate. We will then take a look at FusionReactor and see how it picks up this issue. For the test environment, we are using Microservices, SpringBoot, and Eclipse in conjunction with FusionReactor.

Java, Spring Boot and Red Hat OpenShift troubleshooting with FusionReactor

Video by Pierre-Hugues Charbonneau

The scenario

For this example, a 50,000 spin was created on a single request with one megabyte of memory on an empty buffer.

How to Troubleshoot high CPU usage

FusionReactor immediately detects that the CPU is rising

Troubleshooting high CPU usage in Java environments, FusionReactor

Troubleshoot the CPU impact on the garbage collector

We can see that the request did create some garbage collection, we can see that the GC did its job and memory was freed up with no liquid.

The memory heap quickly returned to normal and there is no evidence of a memory leak. 

Troubleshooting high CPU usage in Java environments, FusionReactor

Why did the request impact the GC?

To determine why the request has such a profound effect on the GC we need to drill down a little deeper. Next, we will take a look at the transaction.

FusionReactor Transaction view will allow you to see your top requests, not surprisingly our test request which created the 50,000 CPU spin is at the top of the list

Troubleshooting high CPU usage in Java environments, FusionReactor

FusionReator will detect excessive allocated memory

The General tab gives us the base detail of the request which includes the status and the time it took to run. Scroll down and you will see the detail of the stream and the memory. You may recall GC activity which led us to investigate memory and when we take a look at Transaction Allocated Memory this is 52 megabytes. This matches exactly what we expected when we programmatically made the CPU spin at 50,000 with one megabyte of memory on an empty buffer. 

Take a look at the profile and you will see a code-level view of where the time was spent, FusionReactor will even let you decompile that code on the fly! 

Troubleshooting high CPU usage in Java environments, FusionReactor

What is the process for troubleshooting CPU issues?

Troubleshoot CPU issues with a profiler

The CPU profiler is a CPU sampler that will give you a detailed breakdown of the thread giving breakdown by percentage and number of seconds for each thread. This is similar to JStack for example. The advantage of FusionReactor is that you can also monitor from here as well making FusionReactor a singular solution for chronic CPU issues.

Troubleshooting high CPU usage in Java environments, FusionReactor

How to Troubleshoot high CPU usage

FusionReactor gives you the tools to drill down to code and thread-level when investigating CPU issues.

Spot issues as they happen using the monitor: