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:
sh
ps 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.