CPU High load Solution idea

Source: Internet
Author: User
Tags high cpu usage

After Tomcat is started on the server, use top to view CPU usage to 200%, although the server is configured with 8 cores, but the business volume is large and cannot be carried. As a result, troubleshoot the problem by using the following methods:

1. View the number of processes with high CPU usage:

650) this.width=650; "title=" image "style=" border-top:0px; border-right:0px; Background-image:none; border-bottom:0px; padding-top:0px; padding-left:0px; border-left:0px; padding-right:0px "border=" 0 "alt=" image "src=" http://s3.51cto.com/wyfs02/M01/6E/E2/ Wkiol1wkt-2rfdevaacrjify5rm475.jpg "" 359 "height="/>

According to the top command, it is found that the Java process with PID 14586 consumes up to 200% CPU and fails.

Via PS aux | grep pid command, you can further determine that there is a problem with the Tomcat process. But how exactly does the problem lie?

show the list of threads first :

PS-MP Pid-o Thread,tid,time

650) this.width=650; "title=" image "style=" border-top:0px; border-right:0px; Background-image:none; border-bottom:0px; padding-top:0px; padding-left:0px; margin:0px; border-left:0px; padding-right:0px "border=" 0 "alt=" image "src=" http://s3.51cto.com/wyfs02/M02/6E/E2/ Wkiol1wkt-3rylzpaabtlshc8oe003.jpg "" 244 "height="/>

650) this.width=650; "title=" image "style=" border-top:0px; border-right:0px; Background-image:none; border-bottom:0px; padding-top:0px; padding-left:0px; margin:0px; border-left:0px; padding-right:0px "border=" 0 "alt=" image "src=" http://s3.51cto.com/wyfs02/M00/6E/E2/ Wkiol1wkt-2h7hajaabc1we425u014.jpg "" 244 "height="/>

Find the most time-consuming thread ID: 14634,14635

Next, convert the required thread ID to 16 binary format:

printf "%x\n" tid

650) this.width=650; "title=" image "style=" border-top:0px; border-right:0px; Background-image:none; border-bottom:0px; padding-top:0px; padding-left:0px; margin:0px; border-left:0px; padding-right:0px "border=" 0 "alt=" image "src=" http://s3.51cto.com/wyfs02/M01/6E/E2/ Wkiol1wkt-7ikstoaaabliwuzyq437.jpg "" 244 "height="/>

650) this.width=650; "title=" image "style=" border-top:0px; border-right:0px; Background-image:none; border-bottom:0px; padding-top:0px; padding-left:0px; margin:0px; border-left:0px; padding-right:0px "border=" 0 "alt=" image "src=" http://s3.51cto.com/wyfs02/M02/6E/E2/ Wkiol1wkt-7gj0xsaaacranupua667.jpg "" 244 "height="/>

Last print thread's stack information:

Jstack PID |grep tid-a 30

650) this.width=650; "title=" image "style=" border-top:0px; border-right:0px; Background-image:none; border-bottom:0px; padding-top:0px; padding-left:0px; margin:0px; border-left:0px; padding-right:0px "border=" 0 "alt=" image "src=" http://s3.51cto.com/wyfs02/M00/6E/E2/wKioL1WKt--Bq_ Hjaacwa-2qmrq814.jpg "" 244 "height=" 148 "/>

Again, look at the other thread. This is also the case, after analysis, developed that the previous version of the thread to obtain data has been waiting, the change version is: every 5 minutes to start the process, add container functions and so on. The details have to be developed to understand.

Finally, summarize the methods and techniques for troubleshooting CPU failures:

1. Top command: Linux command. You can view real-time CPU usage. You can also view CPU usage for the most recent period of time.

2, PS command: Linux command. Powerful process status monitoring commands. You can view the current CPU usage of the process and threads in the process. The sampled data that belongs to the current state.

3, the Jstack:java provides the command. You can view the current thread stack run of a process. Depending on the output of this command, you can locate the current running state of all threads of a process, run code, deadlock, and so on.

4, Pstack:linux command. You can view the current thread stack run of a process.

CPU High load Solution idea

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.