Record a long-term 100% troubleshooting of Linux server CPU
background
Troubleshooting steps
-
Log in to the server, check the process with the highest CPU consumption, and execute top -c It is found that the Java program causes the high CPU; -
Check the server log to see if the request volume is too large and the machine performance is poor. After checking, this is not the reason, so go to the next step; -
Because the Docker deployment is used, the host cannot locate the specific problem by checking the pid. Here we directly use arthas Positioning to specific problems; docker stats Check the container with the highest CPU consumption, and then use the Docker exec - it {container id}/bin/bash Enter the container ; -
Because the Docker installation is to minimize the image, there is no jdk environment, only the jre running environment, and it cannot be executed like jps Command, so first temporarily install a jdk in the docker container, and then start arthas Conduct troubleshooting; The steps to install the jdk and start the arthas command are as follows: #Download jdk wget https://mirrors.huaweicloud.com/java/jdk/8u202-b08/jdk-8u202-linux-x64.tar.gz #Decompress tar -zxvf jdk-8u202-linux-x64.tar.gz #Download arthas wget https://arthas.aliyun.com/arthas-boot.jar #Start arthas ./jdk-8u202-linux-x64/bin/java -jar arthas-boot.jar -
implement thead -n 3 Check the three busiest threads of the CPU and record the pid; Continue execution Thead pid number , locate the specific code, and my log is as follows: [ arthas@1 ]$ thread 5781 "http-nio-8080-exec-211" Id=5781 RUNNABLE at java.util.regex.Pattern$CharProperty.match(Pattern.java:3778) at java.util.regex.Pattern$Branch.match(Pattern.java:4606) at java.util.regex.Pattern$GroupHead.match(Pattern.java:4660) at java.util.regex.Pattern$Loop.match(Pattern.java:4787) at java.util.regex.Pattern$GroupTail.match(Pattern.java:4719) at java.util.regex.Pattern$BranchConn.match(Pattern.java:4570) at java.util.regex.Pattern$CharProperty.match(Pattern.java:3779) at java.util.regex.Pattern$Branch.match(Pattern.java:4606) at java.util.regex.Pattern$GroupHead.match(Pattern.java:4660) at java.util.regex.Pattern$Loop.match(Pattern.java:4787) at java.util.regex.Pattern$GroupTail.match(Pattern.java:4719) at java.util.regex.Pattern$BranchConn.match(Pattern.java:4570) at java.util.regex.Pattern$CharProperty.match(Pattern.java:3779) at java.util.regex.Pattern$Branch.match(Pattern.java:4606) at java.util.regex.Pattern$GroupHead.match(Pattern.java:4660) at java.util.regex.Pattern$Loop.match(Pattern.java:4787) at java.util.regex.Pattern$GroupTail.match(Pattern.java:4719) at java.util.regex.Pattern$BranchConn.match(Pattern.java:4570) at java.util.regex.Pattern$CharProperty.match(Pattern.java:3779)
Analysis results
summary
Reference link
Official document of Java diagnostic tool arthas
Troubleshooting 100% Java Process CPU Problems
Troubleshooting of Java application CPU soaring (more than 100%)
Regex gone wild: java.util.regex.Pattern matcher goes into high CPU loop