Online problem handling 1---CPU soaring high problem location

Online cpu high troubleshooting steps: 

method one: 

  1. top command to view process and CPU usage
  2. Judging whether GC causes the CPU to rush high mainly depends on the GC frequency and memory usage. For specific commands, please refer to:  jvm common commands
  3. If it is not a GC problem, top -Hp PID to view the thread situation of the process with the highest CPU usage
    1. After determining the thread, calculate the hexadecimal value corresponding to the thread ID: printf "%x\n" <java_thread_id> 
    2. Output the thread stack content: jstack <java_pid> | grep <thread id hexadecimal value> -A 30 [-A 30 means print 30 lines down], then you can see which part of the business code makes the CPU Soaring high. The information here can be accurate to the class, method, and line number of java code: 
  4. According to the result of the third step, modify the business logic code

Method Two: 

        1. Export the stack information corresponding to the thread in method 1: 

jstack PID > stack.text

        2、将导出的文件上传到: gceasy.io/ft-index.jsp  Smart Java thread dump analyzer - thread dump analysis in secondsFree online thread dump analyzer to troubleshoot Java, android applications. Kotlin, Clojure, Scala, Jruby, Jython, all JVM language thread dumps are supported. hs_err_pid, core dump files are analyzed.https://gceasy.io/ft-index.jsp          

 After the upload is complete, the file will be analyzed and the following information will be obtained: 

Top command and parameter description: 

1. Check online CPU usage: top command

 In the picture above, the output of my top command is not the same as your output. My font is red, and it shows the number of cpus and the private use of each, as well as the use of memory is a graph structure. And your top command screenshot should look like this: 

This requires remembering several keys and functions: 

  • Press z to change the color of the top trace
  • Press 1 to see a graphical representation of each CPU core on the system
  • The m key displays memory usage graphically
  • t graphical display of CPU usage

1.1 top parameter information 

  1. up *** days, *** min : indicates that this server runs continuously for *** days *** minutes
  2. *** users : the number of currently logged in users 
  3. load average: ***, ***, *** : System load, that is, the average length of the task queue. The three values ​​are the average value from 1 minute, 5 minutes, and 15 minutes ago to the present

1.2 Tasks system tasks 

  1.  total: the total number of processes
  2. running: the number of processes being executed
  3. sleeping : the number of processes that are sleeping
  4. stopped : number of suspended processes
  5. zombie: number of zombie processes

1.3 %Cpu System CPU usage 

  1. us : system user occupation ratio
  2. sy: system core occupancy ratio
  3. ni: priority scheduling occupation ratio
  4. id: idle CPU
  5. wa: I/O equal occupation ratio
  6. hi: hardware interrupt occupation
  7. si: software interrupt occupied
  8.  st: virtualization occupied

1.4 Kib Mem system memory usage

  1. total: total memory space
  2. free: free memory
  3. used: used
  4. buff/cache: The sum of the buffers of physical memory and swap memory.

1.5 Kib Swap system swap space usage

  1. total: total swap space
  2. free: free swap space
  3. used: used swap space
  4. avail Mem: available physical space.

1.6 Running process information, which is also the most commonly used data

  1. PID: Process ID
  2. USER: process owner
  3. PR: priority
  4. NI: process priority
  5. VIRT: virtual memory
  6. RES: the actual physical memory used
  7. SHR: shared memory size
  8. S: Process state (D=uninterruptible sleep state, R=running or runnable, S=sleeping, T means tracked and stopped, Z=zombie
  9. %CPU: The percentage of cpu time occupied since the last update
  10. %MEM: The percentage of physical memory used by the process
  11. TIME+: total cpu time used by the process
  12. COMMAND: command name/command line

2. Common parameters of the top command: analyze the specific thread top -Hp PID

  1. 1.   H: Display thread
  2. 2.  p: Sort according to the percentage of CPU usage.

 After using the top -Hp PID command, the displayed information is somewhat different from the top command: instead of Task, it shows Threads, which identifies the total number of threads in the current process.

Reference documents: 

        Detailed explanation of the top command

Guess you like

Origin blog.csdn.net/zhoushimiao1990/article/details/126087610