idl linux运行效率,Linux性能监控之CPU篇

正如我们之前讨论的任何系统的性能比较都是基于基线的,并且监控CPU的性能就是以上3点,运行队列、CPU使用率和上下文切换。以下是一些对于CPU很普遍的性能要求:

1. 对于每一个CPU来说运行队列不要超过3,例如,如果是双核CPU就不要超过6;

2. 如果CPU在满负荷运行,应该符合下列分布,

a) User Time:65%~70%

b) System Time:30%~35%

c) Idle:0%~5%

3. 对于上下文切换要结合CPU使用率来看,如果CPU使用满足上述分布,大量的上下文切换也是可以接受的。

常用的监视工具有,vmstat, top,dstat和mpstat.[@more@]# vmstat 1

procs -----------memory---------- ---swap-- -----io---- --system-- ----cpu----

r b swpd free buff cache si so bi bo in cs us sy id wa

0 0 104300 16800 95328 72200 0 0 5 26 7 14 4 1 95 0

0 0 104300 16800 95328 72200 0 0 0 24 1021 64 1 1 98 0

0 0 104300 16800 95328 72200 0 0 0 0 1009 59 1 1 98 0

r表示运行队列的大小,

b表示由于IO等待而block的线程数量,

in表示中断的数量,

cs表示上下文切换的数量,

us表示用户CPU时间,

sys表示系统CPU时间,

wa表示由于IO等待而是CPU处于idle状态的时间,

id表示CPU处于idle状态的总时间。

dstat可以给出每一个设备产生的中断数:

# dstat -cip 1

----total-cpu-usage---- ----interrupts--- ---procs---

usr sys idl wai hiq siq| 15 169 185 |run blk new

6 1 91 2 0 0| 12 0 13 | 0 0 0

1 0 99 0 0 0| 0 0 6 | 0 0 0

0 0 100 0 0 0| 18 0 2 | 0 0 0

0 0 100 0 0 0| 0 0 3 | 0 0 0

我们可以看到这里有3个设备号15,169和185.设备名和设备号的关系我们可以参考文件/proc/interrupts, 这里185代表网卡eth1.

# cat /proc/interrupts

CPU0

0: 1277238713 IO-APIC-edge timer

6: 5 IO-APIC-edge floppy

7: 0 IO-APIC-edge parport0

8: 1 IO-APIC-edge rtc

9: 1 IO-APIC-level acpi

14: 6011913 IO-APIC-edge ide0

15: 15761438 IO-APIC-edge ide1

169: 26 IO-APIC-level Intel 82801BA-ICH2

185: 16785489 IO-APIC-level eth1

193: 0 IO-APIC-level uhci_hcd:usb1

mpstat可以显示每个CPU的运行状况,比如系统有4个CPU。我们可以看到:

# mpstat –P ALL 1

Linux 2.4.21-20.ELsmp (localhost.localdomain) 05/23/2006

05:17:31 PM CPU %user %nice %system %idle intr/s

05:17:32 PM all 0.00 0.00 3.19 96.53 13.27

05:17:32 PM 0 0.00 0.00 0.00 100.00 0.00

05:17:32 PM 1 1.12 0.00 12.73 86.15 13.27

05:17:32 PM 2 0.00 0.00 0.00 100.00 0.00

05:17:32 PM 3 0.00 0.00 0.00 100.00 0.00

总结的说,CPU性能监控包含以下方面:

检查系统的运行队列,确保每一个CPU的运行队列不大于3.

确保CPU使用分布满足70/30原则(用户70%,系统30%)。

如果系统时间过长,可能是因为频繁的调度和改变优先级。

CPU Bound进程总是会被惩罚(降低优先级)而IO Bound进程总会被奖励(提高优先级)。

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/7201003/viewspace-1004621/,如需转载,请注明出处,否则将追究法律责任。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值