Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the troubleshooting process of JVM's CPU resources taking up too much resources?

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

Today, I will talk to you about the process of troubleshooting the problem of excessive occupation of CPU resources in JVM. Many people may not know much about it. In order to make you understand better, the editor has summarized the following contents for you. I hope you can get something according to this article.

The CPU percentage of a JVM in an app on the noon line suddenly soared to 192% and couldn't go down all the time, causing the monitoring to warn all the time. This problem has not been dealt with for a long time. Now summarize and record the troubleshooting steps. (none of the following pictures are screenshots of online problems, which involve the company's business.)

1. Check the CPU usage of the current machine through the top command

At this point, it is found that if the Java process occupies too much and cannot get down all the time, then troubleshoot what thread is causing the proportion to be too high. Take the process in the figure as an example. If it is found that the Java process with a PID of 31357 accounts for a high ratio of CPU, record its PID.

two。 Check the occupancy of threads in the Java process

Top-H-p 31357

Description:-H refers to the display thread, and-p is the specified process

You can see that CPU takes up more threads, so write down their PID, assuming that 31357 of CPU has always been 50%.

3. Get the thread stack with resource exception through the jstack command, which can be temporarily saved to a file to view

Jstack 31357 > jstack.31357.log

You can see the stack information for the specified thread above.

If you want to see additional information about locks in a thread, you can add a-l parameter

4. The above method is used for stack printing when the process is normal. Today, there is no response with the jstack-l command. It is estimated that CPU has been standing and cannot execute the normal command. According to the prompt [The-F option can be used when the target process is not responding], you can only play a big trick.

Jstack-F "PID" > jstack. "PID" .txt

The actual log result is as follows:

A large pile of threads are found to be blocked, and the useful results are here:

Obviously, the thread that has been running is 19576, which has been executing the relevant methods of EXCEL export. This is the problem. The next task is to check the code logic of this place.

Jstack command format:

Jstack [option] pid

Parameter description:

Force the print stack when the F jstack [- l] pid fails to respond

-l l long list. Print additional information about the lock, such as a list of ownable synchronizers belonging to java.util.concurrent.

The-m mixed mode output (including the java and native cripple + fragments) stack.

Pid: the process number of the java application

If you remember correctly, these parameters are mutually exclusive and cannot be used together.

5. Later, it was found that it was more practical to use the jps command to view the pid of the java process:

Command format

Jps [options] [hostid]

Parameter description

-m outputs the parameters passed to the main method, or null if it is an embedded JVM.

-l outputs the full package name of the application's main class, or the full path to the application's JAR file.

-v outputs the parameters passed to JVM.

The three parameters add up to show more detailed information:

It is found that the remote port of JMX is open in the startup parameters of these Java processes, and normally you can see the daily parameters of JVM through the jconsole remote connection. For example, local access to the pay.war process in the figure above:

After reading the above, do you have any further understanding of the troubleshooting process of JVM's excessive use of CPU resources? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report