使用“ps”命令时,“%cpu”列在具有多核处理器时意味着什么?
Using the `ps` command, what does the `%cpu` column mean when having a processor with multiple cores?
查看关于我的CPU架构的信息:
root@jai [~]# lscpu
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
CPU(s): 16
On-line CPU(s) list: 0-15
Thread(s) per core: 1
Core(s) per socket: 1
Socket(s): 16
NUMA node(s): 1
Vendor ID: GenuineIntel
CPU family: 6
Model: 86
Model name: Intel(R) Xeon(R) CPU D-1541 @ 2.10GHz
Stepping: 3
CPU MHz: 2099.998
BogoMIPS: 4199.99
Hypervisor vendor: KVM
Virtualization type: full
L1d cache: 32K
L1i cache: 32K
L2 cache: 4096K
L3 cache: 16384K
NUMA node0 CPU(s): 0-15
我的网站性能很差,有时会间歇性地工作,一次不能完全加载页面,但几秒钟后可以正常加载所有页面。完全断断续续,同样的事情发生在不同地点的不同电脑和手机上。我怀疑问题是由于超出了我的 CPU 处理流量的能力,并处理了当时我是 运行 的情况。所以我 运行 在遇到问题时执行了以下命令。查看结果:
root@cup [~]# ps -eo pid,ppid,cmd,%mem,%cpu --sort=-%cpu | more
PID PPID CMD %MEM %CPU
26468 1499 php-fpm: pool m_jaimemontoya_n 1.0 57.3
26463 1499 php-fpm: pool m_jaimemontoya_n 0.7 42.3
26553 1499 php-fpm: pool m_jaimemontoya_n 0.6 38.5
26502 1499 php-fpm: pool m_jaimemontoya_n 0.2 35.6
26190 1499 php-fpm: pool m_jaimemontoya_n 0.3 29.4
18242 1499 php-fpm: pool m_jaimemontoya_n 1.1 22.8
19045 1499 php-fpm: pool m_jaimemontoya_n 1.0 20.6
18437 1499 php-fpm: pool m_jaimemontoya_n 0.6 20.2
18269 1499 php-fpm: pool m_jaimemontoya_n 1.1 18.5
18289 1499 php-fpm: pool m_jaimemontoya_n 0.9 13.1
19042 1499 php-fpm: pool m_jaimemontoya_n 1.1 11.9
26906 1 /usr/sbin/exim -Mc 1jTsTl-0 0.0 7.0
8546 8014 /usr/sbin/mysqld --basedir= 1.1 6.7
26872 1 /usr/sbin/exim -Mc 1jTsTl-0 0.0 6.0
26877 1 /usr/sbin/exim -Mc 1jTsTl-0 0.0 6.0
26869 1 /usr/sbin/exim -Mc 1jTsTl-0 0.0 5.0
26875 21851 /usr/sbin/exim -qG 0.0 5.0
26885 1 /usr/sbin/exim -Mc 1jTsTl-0 0.0 5.0
26891 1 /usr/sbin/exim -Mc 1jTsTl-0 0.0 5.0
26895 1 /usr/sbin/exim -Mc 1jTsTl-0 0.0 5.0
26888 1 /usr/sbin/exim -Mc 1jTsTl-0 0.0 4.0
26903 1 /usr/sbin/exim -Mc 1jTsTl-0 0.0 4.0
26880 26875 /usr/sbin/exim -qG 0.0 3.0
26881 26869 /usr/sbin/exim -Mc 1jTsTl-0 0.0 3.0
26882 26872 /usr/sbin/exim -Mc 1jTsTl-0 0.0 3.0
26899 26888 /usr/sbin/exim -Mc 1jTsTl-0 0.0 3.0
17419 1499 php-fpm: pool jaimemontoya_com 0.0 2.5
26814 1 /usr/sbin/exim -Mc 1jTsTj-0 0.0 2.5
26849 1 /usr/sbin/exim -Mc 1jTsTk-0 0.0 2.5
21290 1499 php-fpm: pool jaimemontoya_com 0.0 2.1
14959 1499 php-fpm: pool jaimemontoya_com 0.0 2.0
16122 1499 php-fpm: pool jaimemontoya_com 0.0 2.0
17085 1499 php-fpm: pool jaimemontoya_com 0.0 2.0
22367 1499 php-fpm: pool jaimemontoya_com 0.0 2.0
26826 1 /usr/sbin/exim -Mc 1jTsTk-0 0.0 2.0
26859 26849 /usr/sbin/exim -Mc 1jTsTk-0 0.0 2.0
26884 26877 /usr/sbin/exim -Mc 1jTsTl-0 0.0 2.0
26902 26895 /usr/sbin/exim -Mc 1jTsTl-0 0.0 2.0
18723 1499 php-fpm: pool jaimemontoya_com 0.0 1.7
21456 1499 php-fpm: pool jaimemontoya_com 0.0 1.7
21975 1499 php-fpm: pool jaimemontoya_com 0.0 1.7
13578 1499 php-fpm: pool jaimemontoya_com 0.0 1.6
我想了解如何解释 %CPU
列。如果我将以下值相加,我将得到 404.2 作为总数:
57.3+42.3+38.5+35.6+29.4+22.8+20.6+20.2+18.5+13.1+11.9+7.0+6.7+6.0+5.0+5.0+5.0+5.0+5.0+4.0+4.0+3.0+3.0+3.0+2.5+2.5+2.5+2.1+2.0+2.0+2.0+2.0+2.0+2.0+2.0+2.0+1.7+1.7+1.7+1.6
考虑到我有 16 个 CPU,我如何解释将所有进程的 %CPU
列中的所有值相加后得到的 404.2
?我有一台 30 GB RAM 的服务器,8 核/16 线程 CPU。谢谢。
注意:过去我经常在我的服务器日志中收到此警告:WARNING: [pool m_jaimemontoya_com] server reached max_children setting (5), consider raising it
所以我将其提高到 32。因此,您看到 php-fpm
已处理超过 5 个运行同时。
更新 1:
使用 man lscpu
,我看到了这个:
COLUMNS
CPU The logical CPU number of a CPU as used by the Linux kernel.
我让 AbraCadaver 写下他的评论作为答案,因为那是我的解决方案。他没有这样做。我在下面复制他的评论作为我问题的答案:
"That's a bad data point for ps
CPU% is CPU usage is currently expressed as the percentage of time spent running during the entire lifetime of a process. Might look at top
or other utility. – AbraCadaver Apr 29 at 20:41"
查看关于我的CPU架构的信息:
root@jai [~]# lscpu
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
CPU(s): 16
On-line CPU(s) list: 0-15
Thread(s) per core: 1
Core(s) per socket: 1
Socket(s): 16
NUMA node(s): 1
Vendor ID: GenuineIntel
CPU family: 6
Model: 86
Model name: Intel(R) Xeon(R) CPU D-1541 @ 2.10GHz
Stepping: 3
CPU MHz: 2099.998
BogoMIPS: 4199.99
Hypervisor vendor: KVM
Virtualization type: full
L1d cache: 32K
L1i cache: 32K
L2 cache: 4096K
L3 cache: 16384K
NUMA node0 CPU(s): 0-15
我的网站性能很差,有时会间歇性地工作,一次不能完全加载页面,但几秒钟后可以正常加载所有页面。完全断断续续,同样的事情发生在不同地点的不同电脑和手机上。我怀疑问题是由于超出了我的 CPU 处理流量的能力,并处理了当时我是 运行 的情况。所以我 运行 在遇到问题时执行了以下命令。查看结果:
root@cup [~]# ps -eo pid,ppid,cmd,%mem,%cpu --sort=-%cpu | more
PID PPID CMD %MEM %CPU
26468 1499 php-fpm: pool m_jaimemontoya_n 1.0 57.3
26463 1499 php-fpm: pool m_jaimemontoya_n 0.7 42.3
26553 1499 php-fpm: pool m_jaimemontoya_n 0.6 38.5
26502 1499 php-fpm: pool m_jaimemontoya_n 0.2 35.6
26190 1499 php-fpm: pool m_jaimemontoya_n 0.3 29.4
18242 1499 php-fpm: pool m_jaimemontoya_n 1.1 22.8
19045 1499 php-fpm: pool m_jaimemontoya_n 1.0 20.6
18437 1499 php-fpm: pool m_jaimemontoya_n 0.6 20.2
18269 1499 php-fpm: pool m_jaimemontoya_n 1.1 18.5
18289 1499 php-fpm: pool m_jaimemontoya_n 0.9 13.1
19042 1499 php-fpm: pool m_jaimemontoya_n 1.1 11.9
26906 1 /usr/sbin/exim -Mc 1jTsTl-0 0.0 7.0
8546 8014 /usr/sbin/mysqld --basedir= 1.1 6.7
26872 1 /usr/sbin/exim -Mc 1jTsTl-0 0.0 6.0
26877 1 /usr/sbin/exim -Mc 1jTsTl-0 0.0 6.0
26869 1 /usr/sbin/exim -Mc 1jTsTl-0 0.0 5.0
26875 21851 /usr/sbin/exim -qG 0.0 5.0
26885 1 /usr/sbin/exim -Mc 1jTsTl-0 0.0 5.0
26891 1 /usr/sbin/exim -Mc 1jTsTl-0 0.0 5.0
26895 1 /usr/sbin/exim -Mc 1jTsTl-0 0.0 5.0
26888 1 /usr/sbin/exim -Mc 1jTsTl-0 0.0 4.0
26903 1 /usr/sbin/exim -Mc 1jTsTl-0 0.0 4.0
26880 26875 /usr/sbin/exim -qG 0.0 3.0
26881 26869 /usr/sbin/exim -Mc 1jTsTl-0 0.0 3.0
26882 26872 /usr/sbin/exim -Mc 1jTsTl-0 0.0 3.0
26899 26888 /usr/sbin/exim -Mc 1jTsTl-0 0.0 3.0
17419 1499 php-fpm: pool jaimemontoya_com 0.0 2.5
26814 1 /usr/sbin/exim -Mc 1jTsTj-0 0.0 2.5
26849 1 /usr/sbin/exim -Mc 1jTsTk-0 0.0 2.5
21290 1499 php-fpm: pool jaimemontoya_com 0.0 2.1
14959 1499 php-fpm: pool jaimemontoya_com 0.0 2.0
16122 1499 php-fpm: pool jaimemontoya_com 0.0 2.0
17085 1499 php-fpm: pool jaimemontoya_com 0.0 2.0
22367 1499 php-fpm: pool jaimemontoya_com 0.0 2.0
26826 1 /usr/sbin/exim -Mc 1jTsTk-0 0.0 2.0
26859 26849 /usr/sbin/exim -Mc 1jTsTk-0 0.0 2.0
26884 26877 /usr/sbin/exim -Mc 1jTsTl-0 0.0 2.0
26902 26895 /usr/sbin/exim -Mc 1jTsTl-0 0.0 2.0
18723 1499 php-fpm: pool jaimemontoya_com 0.0 1.7
21456 1499 php-fpm: pool jaimemontoya_com 0.0 1.7
21975 1499 php-fpm: pool jaimemontoya_com 0.0 1.7
13578 1499 php-fpm: pool jaimemontoya_com 0.0 1.6
我想了解如何解释 %CPU
列。如果我将以下值相加,我将得到 404.2 作为总数:
57.3+42.3+38.5+35.6+29.4+22.8+20.6+20.2+18.5+13.1+11.9+7.0+6.7+6.0+5.0+5.0+5.0+5.0+5.0+4.0+4.0+3.0+3.0+3.0+2.5+2.5+2.5+2.1+2.0+2.0+2.0+2.0+2.0+2.0+2.0+2.0+1.7+1.7+1.7+1.6
考虑到我有 16 个 CPU,我如何解释将所有进程的 %CPU
列中的所有值相加后得到的 404.2
?我有一台 30 GB RAM 的服务器,8 核/16 线程 CPU。谢谢。
注意:过去我经常在我的服务器日志中收到此警告:WARNING: [pool m_jaimemontoya_com] server reached max_children setting (5), consider raising it
所以我将其提高到 32。因此,您看到 php-fpm
已处理超过 5 个运行同时。
更新 1:
使用 man lscpu
,我看到了这个:
COLUMNS
CPU The logical CPU number of a CPU as used by the Linux kernel.
我让 AbraCadaver 写下他的评论作为答案,因为那是我的解决方案。他没有这样做。我在下面复制他的评论作为我问题的答案:
"That's a bad data point for ps
CPU% is CPU usage is currently expressed as the percentage of time spent running during the entire lifetime of a process. Might look at top
or other utility. – AbraCadaver Apr 29 at 20:41"