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
1. First stop the mysql service As an administrat...
This article uses examples to describe the common...
I collected a lot of them, but all ended in failu...
WeChat applet: Simple calculator, for your refere...
Div solution when relative width and absolute wid...
The ps command in Linux is the abbreviation of Pr...
Insert image tag <IMG> The colorful web page...
I don't expect to be an expert DBA, but when ...
Table of contents Step 1: Install node_modules in...
Uninstall the system-provided MySQL 1. Check whet...
Table of contents Same Origin Policy Ajax request...
Table of contents Scenario Core Issues Status mon...
The default port number of the Windows server rem...
Table of contents Initialize MySQL Install MySQL ...
Table of contents 1. Container lifecycle manageme...