In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
How to locate the problem of CPU soaring 100% in production, I believe many inexperienced people do not know what to do about it. Therefore, this paper summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.
In a nutshell, there are three steps:
1, first find out which process's CPU share has soared to 100%.
2. Locate the thread according to the process number pid, and find the tid of the corresponding thread.
3. Export the dump log file of the corresponding thread, and analyze the specific code for locating the log file.
To solve this problem, you should have the following skills:
1the top command of Linux.
2 jps, a JVM monitoring tool.
Jstack, a monitoring tool for JVM.
OK, let's take a closer look at how to locate the problem.
First, how to use the top command of linux
Linux's top command is similar to the task manager under windows, and we can use the linux command to view the cpu usage of the production server.
Common commands are as follows:
Top: displays the resource usage of all processes every 5 seconds.
Top-d 2: displays the resource usage of all processes every 2 seconds.
Top-c: displays the resource usage of all processes every 5 seconds, and displays the command line parameters of the process (only the process name is the default).
Top-p 12345-p 6789: displays the resource utilization of 12345 and 6789 processes every 5 seconds.
Top-d 2-c-p 123456: displays the resource consumption of a process with a PID of 12345 every 2 seconds, and displays the command line parameters that the process starts.
OK, we can use the following command to view the CPU usage of all threads under a thread:
Top-H-p pid
For example, find the usage of all threads under a process with process number 12345:
Top-H-p 12345
OK, we are one step closer to the goal. According to PID, we found tid, and then we will use another command: jstack. Finding thread id means that the rest of the work will be left to the analysis tools provided by jvm. The operating system can only help us so far.
Second, jvm monitoring tool jps
The top command is powerful, but we can also use the jps profiling tool provided by jvm, which is jvm's proprietary process profiling tool.
Jps-lvm: view the java processes running on the current server. We can get the pid of the java application.
Next we use the jstack-l pid command to view the stack information of the java application.
In short, there are two ways to get the pid of a java application.
1, use the top command
2, use the jps command
The function of jps is similar to the ps command of linux, which is used to view the running information of the process. Let's take a look at what the specific parameters mean.
Jps-Q: only the process id is listed. Note that the jvm process is listed here, and the non-jvm process jps is powerless.
Jps-m: lists the parameters passed to the main method when the application is started.
Jps-l: lists the jvm process id and the full name of the running main class.
Jps-v: lists the jvm parameters when the jvm process starts.
Third, jstack performance analysis tools
Jstack can export information such as the running status and current status of a thread. The command is as follows:
Jstack 98765 > 98765jstack.log
We can either pull the log locally for analysis or analyze it directly on linux. In short, we found the log file and knew that some information about thread 98765 was recorded in the file. The next step is to look at the log file and locate the location of the specific code.
Fourth, how to analyze the log file to locate the specific code
The log files exported by jstack may contain the following key information:
1Magical Deadlock: deadlock.
2Jol runnable: executing.
3Waiting for condition: wait for resources.
4 waiting on monitor entry: wait for the monitor to be acquired.
5Jing suspended: pause.
6Jing Object.wait () or TIMED_WAITING: object waiting.
7 Barrier: blocking
8pm parked: stop
The problem with soaring CPU is that the thread state is usually Runnable. After we find the state information of the thread, and then analyze the detailed stack information below, we can roughly locate the code that went wrong.
Here are a few more signs that we need to know:
Tid:java thread id.
Nid:native thread id.
Prio: thread priority.
After reading the above, do you know how to locate the problem of CPU soaring 100% in production? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.