设为首页 收藏本站
查看: 3421|回复: 0

[经验分享] vmware中如何检查cpu的使用状况-一个考题引发的思考

[复制链接]

尚未签到

发表于 2015-4-6 20:57:29 | 显示全部楼层 |阅读模式
  来自一个VCP的考题,有点兴趣。可参看:
如何在VMware里使用esxtop?
  http://thocm.com/a/caozuoxitongzixun/xunihuazonghezixun/VMwarexunih/2012/0922/9326.html
  原文http://www.daemonlord.nl/index.php?action=artikel&cat=10&id=85&artlang=en
Interpreting esxtop Statistics
  https://communities.vmware.com/docs/DOC-9279?decorator=print
  如图:
DSC0000.png
  问题:为了排查某服务器遭遇的性能问题,使用esxtop观测,根据如上esxtop的输出结果,请问Fileserver01分配了几个vCPU?
DSC0001.png
  1.CPU load average
  这里会显示3个值,分别是1分钟,5分钟,15分钟间隔内的物理CPU平均负载.
  这3个值每隔5秒钟更新一次。
  如果值为1表示cpu使用率100%。0.5表示50%使用率。如果是2那么显然是超载了,要么增加物理cpu,要么减少虚拟机数量。
  2.PCPU行指示单个核心的使用率
  物理cpu的负载。avg是平均值。一般来说80%比较理想(依据不同场景而定不一定非得80%为基准),90%一般可以看做是接近超载的状态了。
  如果超线程开启会显示LCPU。
  PCPU USED在超线程开启的情况下会和PCPU UTIL不同。
  单个物理CPU或者内核作为两个逻辑CPU使用。内核是CPU中的物理硬件块,而线程是软件生成的,并且和缓存、寄存器以及执行单元一样共享硬件组件。由于这种超线程的存在,CPU USED%和PCPU UTIL%因CPU调度器记录使用状况的不同而不同。如果2个线程同时在忙碌状态,则有效使用率只有一半。 PCPU USED(%) – Physical hardware execution context. Can be a physical CPU core if hyperthreading is unavilable or disabled or a logical CPU (LCPU) or SMT thread if hyperthreading is enabled. This displays PCPU percentage of CPU usage when averaged over all PCPUs.

PCPU UTIL(%) - Physical CPU utilised. (real time) Indicates how much time the PCPU was busy, in an unhalted state, in the last snapshot duration. Might differ from PCPU USED(%) due to power management technologies or hyperthreading.

If hyper threading is enabled these figures can be different, likewise if the frequency of the PCPU is changed due to power management these figures can also be adjusted.

As an example if PCPU USED(%) is 100 and PCPU UTIL(%) is 50 this is because hyper threading is splitting the load across the two PCPUs. If you then look in the vSphere client you may notice that CPU usage is 100%. This is because the vSphere client will double the statistics if hyperthreading is enabled.

In a dual core system, each PCPU is charged by the CPU scheduler half of the elapsed time when both PCPUs are busy.

  
  重要解释:


  •   "PCPU USED(%)"
The percentage CPU usage per PCPU, and its average over all PCPUs.


Q: What is the difference between "PCPU UTIL(%)" and "PCPU USED(%)"?

A: While "PCPU UTIL(%)" indicates how much time a PCPU was busy (unhalted) in the last duration, "PCPU USED(%)" shows the amount of "effective work" that has been done by this PCPU. The value of "PCPU USED(%)" can be different from "PCPU UTIL(%)" mainly for the following two reasons:


(1) Hyper-threading

The two PCPUs in a core share a lot of hardware resources, including the execution units and cache. And thus, the "effective work" done by a PCPU when the other PCPU in the core is busy is usually much less than the case when the other PCPU is idle. Based on this observation, our CPU scheduler charges each PCPU half of the elapsed durating when both PCPUs are busy. If only one PCPU is busy during a time period, the PCPU is charged for all that time period. Let's use some examples to illustrate this.





  • '+' means busy, '-' means idle.  
  • (1) PCPU 0:   +++++----- (UTIL: %50 / USED: %50)  
  •     PCPU 1:   -----+++++ (UTIL: %50 / USED: %50)  
  • (2) PCPU 0:   +++++----- (UTIL: %50 / USED: %25)  
  •     PCPU 1:   +++++----- (UTIL: %50 / USED: %25)  
  • (3) PCPU 0:   +++++----- (UTIL: %50 / USED: %40, i.e. %30 + 20%/2)  
  •     PCPU 1:   ---+++++-- (UTIL: %50 / USED: %40, i.e. %20/2 + %30)  

In all the three above scenarios, each PCPU is utilized by 50%. But, depending on whether they are busy at the same time, the PCPU USED(%) is between 25% and 50%. Generally speaking,





  •                                      /- PCPU0_UTIL%/2, if PCPU0_UTIL% < PCPU1_UTIL%  
  •        PCPU0_UTIL% >= PCPU0_USED% >= |  
  •                                      \- (PCPU0_UTIL% - PCPU1_UTIL%) + PCPU1_UTIL%/2, otherwise  
Please note that the above inequations may not hold due to frequency scaling, which is discussed next.


(2) Power Management

The frequency of a PCPU may be changed due to power management. Obviously, a PCPU does less "effective work" (in a unit of time) when the frequency is lower. The CPU scheduler adjusts the "PCPU USED(%)" based on the frequency of the PCPU.





  •           PCPU_USED% = PCPU_UTIL% * Effective_Frequency / Nominal_Frequency  

Suppose that UTIL% is 80%, and the nominal frequency is 2 GHz. If the effective frequency is 1.5 GHz. USED% would be 80% * 1.5 / 2 = 60%. Please note that since the CPU frequency may change often, you may go to the esxtop power screen, pressing 'p', to see how often the PCPU stays at what states, which can help guess the effective frequency.


Please also note that turbo mode may make the effective frequency higher than the nominal frequency. In that case, USED% would be higher than UTIL%.


If we want to add both reasons into account, just to make it more complicated, we can have something like this.





  •                       PCPU0_USED%            /- PCPU0_UTIL%/2, if PCPU0_UTIL% < PCPU1_UTIL%  
  •      PCPU0_UTIL% >= * Nomial_Frequency    >= |  
  •                     / Effective_Frequency    \- (PCPU0_UTIL% - PCPU1_UTIL%) + PCPU1_UTIL%/2, otherwise  
Q: Why do I see ~100% for the average "PCPU UTIL(%)", but the average "PCPU USED(%)" is ~50%?

A: It is very likely that hyper-threading is enabled. A PCPU is only charged half the time when both PCPUs are busy. Typically,





  •         0

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-54440-1-1.html 上篇帖子: RedHat虚拟机:Vmware Tools的安装(转) 下篇帖子: 学习Linux一(安装VMware和Ubuntu)
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表