CPU 100%空闲但仍显示平均负载

CPU 100%空闲但仍显示平均负载

我有一台刀片服务器CentOS 6.4

在空闲状态下,它显示恒定的平均负载大于 1。但是,我准备了另一台具有相同硬件和 CentOS 版本的机器,当它空闲时,它的平均负载保持在 0 左右。

top的输出如下:

top - 10:23:04 up 156 days, 18:15,  1 user,  load average: 1.08, 1.35, 1.31
Tasks: 534 total,   1 running, 533 sleeping,   0 stopped,   0 zombie
Cpu(s):  0.0%us,  0.0%sy,  0.0%ni,100.0%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
Mem:  65959040k total, 10021484k used, 55937556k free,   167092k buffers
Swap: 32767992k total,    13884k used, 32754108k free,  7084024k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
20951 root      20   0 15396 1608  952 R  0.3  0.0   0:01.52 top
    1 root      20   0 19352  684  472 S  0.0  0.0   0:01.64 init
    2 root      20   0     0    0    0 S  0.0  0.0   0:00.03 kthreadd
    3 root      RT   0     0    0    0 S  0.0  0.0   0:15.31 migration/0
    4 root      20   0     0    0    0 S  0.0  0.0   0:12.32 ksoftirqd/0
    5 root      RT   0     0    0    0 S  0.0  0.0   0:00.00 migration/0
    6 root      RT   0     0    0    0 S  0.0  0.0   0:17.45 watchdog/0
    7 root      RT   0     0    0    0 S  0.0  0.0   0:16.26 migration/1
    8 root      RT   0     0    0    0 S  0.0  0.0   0:00.00 migration/1
    9 root      20   0     0    0    0 S  0.0  0.0   0:18.51 ksoftirqd/1

哪个进程在完全空闲的情况下导致系统平均负载 > 1?

答案1

平均负载并不意味着你认为的那样。它不是即时 CPU 使用率,而是有多少进程正在等待运行。通常这是因为很多东西都需要 CPU,但并非总是如此。一个常见的罪魁祸首是等待 IO 的进程 - 磁盘或网络。

尝试运行ps -e v并寻找进程状态标志。

state    The state is given by a sequence of characters, for example, "RWNA". The      first character indicates the run state of the process:
D    Marks a process in disk (or other short term, uninterruptible) wait.
I    Marks a process that is idle (sleeping for longer than about 20 seconds).  
L    Marks a process that is waiting to acquire a lock.
R    Marks a runnable process.
S    Marks a process that is sleeping for less than about 20 seconds.
T    Marks a stopped process.
W    Marks an idle interrupt thread.
Z    Marks a dead process (a "zombie").

这是来自ps手册页,因此您可以在其中找到更多详细信息 -R并且D流程可能特别令人感兴趣。

您的顶部输出包含:

Tasks: 534 total,   1 running, 533 sleeping,   0 stopped,   0 zombie

那个正在运行的进程是导致平均负载的原因。找到它,并弄清楚它在做什么。(编辑:正如评论中提到的那样 - 那个running进程可能是top。所以忽略它)

相关内容