CPU surge solution

1. Online server CPU surges, how to locate the problem

The key to solving this problem is to find the location of the Java code. Let’s share the troubleshooting ideas, taking CentOS as an example, and summarize it in 4 steps.

Step 1, use the top command to find the process that consumes a lot of CPU.

Step 2: Use the ps –mp command to find the thread ID that occupies a high amount of CPU under the process.

Step 3, use the printf command to convert the thread ID into a hexadecimal number.

Step 4, use the jstack command to output the log information of the thread running status.

The following describes the operation of each step in detail.

Step 1. After using the top command, you can see a list including PID (process ID), USER (operating user), CPU usage, memory usage, TIME+ (running time), COMMAND (running command), etc. information. By default, the CPU usage is sorted from top to bottom, as shown in the figure below.

We find the row where the COMMAND column is java, indicating that this program is written in Java. Then, use Notepad to write down the PID of this line, which is the process ID.

Step 2, use the ps -mp command to output the thread running status list under this PID, as shown in the figure below.

This list contains several key fields, such as CPU usage, TID &

Guess you like

Origin blog.csdn.net/WXF_Sir/article/details/131702455