The program is a websocket server written in php. messages are sent continuously after the client connects, and the server is responsible for responding to requests. Tested: the time consumed by php on the server side for each request on the client is 1500 to microsecs (the Message Size is different ). The server is a single-core... program is a websocket server written in php. The client continuously sends messages after connection, and the server is responsible for responding to requests.
Tested: the duration consumed by php on the server side is 900 microsecs to 1500 microsecs for each request on the client (the Message Size is different ).
The server is single-core and has 30 clients. Use top to check that the cpu usage of the php process is about 3-5%, and the load average is about 0.05 in 1 minute. Basically meets expectations.
However, sometimes the laod average load is shown as 0.3 or even 0.4 in one minute, and the actual load is 0.2 in five minutes,
However, if you use top (or htop) to view the process, the cpu usage of the php process remains between 3% and 5%, and the cpu usage of other processes is lower than 1%. The total load is far less than the actual load of laod average (30%-40% ).
Strace tracks php processes and does not find any special changes (compared with the previous ones ).
The cpu usage of the process shown in the top is far different from the load average. How can I find out which cpu is occupied?
Reply content:
The program is a websocket server written in php. messages are sent continuously after the client connects, and the server is responsible for responding to requests.
Tested: the duration consumed by php on the server side is 900 microsecs to 1500 microsecs for each request on the client (the Message Size is different ).
The server is single-core and has 30 clients. Use top to check that the cpu usage of the php process is about 3-5%, and the load average is about 0.05 in 1 minute. Basically meets expectations.
However, sometimes the laod average load is shown as 0.3 or even 0.4 in one minute, and the actual load is 0.2 in five minutes,
However, if you use top (or htop) to view the process, the cpu usage of the php process remains between 3% and 5%, and the cpu usage of other processes is lower than 1%. The total load is far less than the actual load of laod average (30%-40% ).
Strace tracks php processes and does not find any special changes (compared with the previous ones ).
The cpu usage of the process shown in the top is far different from the load average. How can I find out which cpu is occupied?
A simple method is to use the htop command (if not, install the htop package ). This is the enhanced version of top, which is also used on the CLI interface. Select CPU Usage for sorting. The first process occupies the highest CPU.
If you do not want to or cannot 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 will output the user's progress to some_file.txt according to the CPU usage sequence. You can see the output file without having to say more.
Atop is the top enhanced version, which contains disk and network information and supports log collection:
/Etc/atop. daily defines the log collection INTERVAL (INTERVAL) of 600 seconds.
The log storage location is/var/log/atop/atop_YYYYMMDD, Which is binary and can be viewed as follows:
Atop-r/var/log/atop/atop_YYYYMMDD press the t key to switch to the next collection point.