PrefaceHigh CPU usage is a common online problem. If you don't know how to do this, it's really a bit disappointing. Don't worry, brother, I'll teach you a combo. startLet's start with a project. The entire API, when we request /cpu/{count}, we can manually increase the CPU. Smart ghost~ @GetMapping("/cpu/{count}") public long cpuTest(@PathVariable("count") long count) { long number = 0; for (int i = 0; i < count; i++) { number++; } return number; } Pack, upload, and start It's running. Remember the process number 14849. Let's first look at the CPU usage under normal circumstances. Very reasonable Simulate online CPU surge We request the /cpu/{100000000000} interface to increase the CPU usage, and use top to observe the CPU usage. Directly work to 98%, very nice OK, let's get started. We have a problem online now. The CPU is always very high. The boss asked you to find the reason and start to support it. In fact, we now know who raised the CPU, but it is not detailed enough. It is far from enough to know which project has the problem. We should find the culprit, which method and how many lines caused the problem, so that the boss can call him an expert. stepjps+top locates the application process pidtop -Hp {pid} find the thread tid Convert tid to hexadecimal printf "%x\n" {tid} Print stack information jstack Filter out what we want TroubleshootingThe process id has been determined to be 14849. The next step is to find which thread is causing the problem. Top -Hp 14849 It's obviously this 14908 who did it. Convert to hexadecimal Print Stack The stack trace shows that the problem is on line 20 in TestController. Let’s go into code verification. No big problem Solve the case Sprinkle flowers This is the end of this article about the detailed troubleshooting process of high CPU speed under Linux. For more relevant content on troubleshooting high CPU speed under Linux, please search 123WORDPRESS.COM's previous articles or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: CSS3 realizes the glowing border effect
>>: Simple example of HTML checkbox and radio style beautification
background go-fastdfs is a distributed file syste...
During the crawler development process, you must ...
1. Single table query -> update UPDATE table_n...
This case is based on CentOS 7 system Suitable fo...
Table of contents 0. What is Webpack 1. Use of We...
Background: Some experiments need to be completed...
Table of contents 1. Introduction to docker-maven...
Knowledge points about Memory storage engine The ...
Two ways to enable proxy React does not have enca...
Table of contents Storage Engine Memory Managemen...
After writing these six articles, I started to fee...
1. Download the successfully generated icon file, ...
1. Compile and install ovs from source code: Inst...
So we introduce an embedding framework to solve th...
As shown below: XML/HTML CodeCopy content to clip...