CPU load suddenly increased under Linux, but top does not see a high CPU consuming process, how to find out what process CPU is occupied?

Source: Internet
Author: User
The program is written by PHP a websocket server, the client is connected to send messages continuously, the service side is responsible for responding to requests.
Tested: Once per request of client, server PHP consumes time of Microsecs to MICROSECS (message size is different).
The server is a single core, 30 clients, using top to view PHP processes occupy CPU around 3-5%, load average 1 minutes load display 0.05 or so. Basically meet expectations.
But sometimes, the laod average 1-minute load shows 0.3 or even 0.4, 5-minute load reality 0.2,
However, using top (or htop) to view the process, it is found that the PHP process CPU is up to 3%-5% and the rest of the process is below 1%. Add up far less than the load of laod average reality (30%-40%).
Strace Tracking the PHP process, no special changes were found (compared with previous).

The CPU usage of the process seen by top is far from the load shown by load average. How can I find out what CPU is occupied?

Reply content:

The program is written by PHP a websocket server, the client is connected to send messages continuously, the service side is responsible for responding to requests.
Tested: Once per request of client, server PHP consumes time of Microsecs to MICROSECS (message size is different).
The server is a single core, 30 clients, using top to view PHP processes occupy CPU around 3-5%, load average 1 minutes load display 0.05 or so. Basically meet expectations.
But sometimes, the laod average 1-minute load shows 0.3 or even 0.4, 5-minute load reality 0.2,
However, using top (or htop) to view the process, it is found that the PHP process CPU is up to 3%-5% and the rest of the process is below 1%. Add up far less than the load of laod average reality (30%-40%).
Strace Tracking the PHP process, no special changes were found (compared with previous).

The CPU usage of the process seen by top is far from the load shown by load average. How can I find out what CPU is occupied?

A simpler approach is to use the Htop command (if not, you need to install the Htop package). This is the enhanced version of top and is also used in the CLI interface. When you open, select CPU usage sequencing, the first one is the one that consumes the highest CPU.

If you are unwilling or unable to install Htop, you can use the following command:

shps aux --sort=-%cpu | awk 'NR==1{print $2,$3,$11}NR>1{if($3!=0.0) print $2,$3,$11}' > some_file.txt

This command sorts the user process by CPU usage and outputs it to the some_file.txt, and you see the output file as you know it, needless to say.

Atop is the enhanced version of top, which contains disk and network information, and supports log capture:
The/etc/atop/atop.daily defines the time interval (INTERVAL) of log acquisition for 600 seconds.
Log storage location/VAR/LOG/ATOP/ATOP_YYYYMMDD, binary content, can be viewed like this:
Atop-r/VAR/LOG/ATOP/ATOP_YYYYMMDD Press the T key to switch to the next acquisition point.

  • 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.