linux中的cpu 负载

性能调优中,经常听到“cpu负载最好不要超过cpu数量”。

 

cpu负载命令

uptime命令,得到如下结果

load average: 1.05, 0.70, 5.09

3个数字,分别表示最近1分钟,5分钟,15分钟的负载分别是1.05,0.70,5.09

 

负载的含义

百度上一堆乱七八糟的资料,还是Wikipedia讲的清楚

For example, one can interpret a load average of "1.73 0.60 7.98" on a single-CPU system as:

  • during the last minute, the system was overloaded by 73% on average (1.73 runnable processes, so that 0.73 processes had to wait for a turn for a single CPU system on average).
  • during the last 5 minutes, the CPU was idling 40% of the time on average.
  • during the last 15 minutes, the system was overloaded 698% on average (7.98 runnable processes, so that 6.98 processes had to wait for a turn for a single CPU system on average).

负载值 - cpu线程数 = 平均有多少个cpu线程在等待cpu时间片。

显然,负载值越高表示系统的压力越大。

如果负载等于cpu线程数,则表示cpu使用率是100%。再高则会出现线程等待。

 

现代多核CPU

以英特尔至强为例,物理核数是4,每个核开了2个线程,则逻辑核数是8.

计算负载时的cpu线程数,用的是8,不是4。

 

cpu使用率和cpu负载的区别

现在公司的线上环境cpu负载超过了8,有时候达到了15,但是cpu使用率只有70%-75%。

cpu使用率表示:在整个程序运行过程中,cpu运行的时间占比。对于高并发的服务器,频繁的线程切换,会导致cpu等待IO,所以cpu的使用率到不到85%的告警但是cpu负载已经比较高了。

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值