来自一个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

如图:

问题:为了排查某服务器遭遇的性能问题,使用esxtop观测,根据如上esxtop的输出结果,请问Fileserver01分配了几个vCPU?

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.

  1. '+' means busy, '-' means idle.
  2. (1) PCPU 0:   +++++----- (UTIL: %50 / USED: %50)
  3. PCPU 1:   -----+++++ (UTIL: %50 / USED: %50)
  4. (2) PCPU 0:   +++++----- (UTIL: %50 / USED: %25)
  5. PCPU 1:   +++++----- (UTIL: %50 / USED: %25)
  6. (3) PCPU 0:   +++++----- (UTIL: %50 / USED: %40, i.e. %30 + 20%/2)
  7. 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,

  1. /- PCPU0_UTIL%/2, if PCPU0_UTIL% < PCPU1_UTIL%
  2. PCPU0_UTIL% >= PCPU0_USED% >= |
  3. \- (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.

  1. 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.

  1. PCPU0_USED%            /- PCPU0_UTIL%/2, if PCPU0_UTIL% < PCPU1_UTIL%
  2. PCPU0_UTIL% >= * Nomial_Frequency    >= |
  3. / 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,

  1. 0 <= PCPU0_USED% + PCPU1_USED% <= 100% * Effective_Frequency / Base_Frequency

Suppose that CPU frequency is fixed to base frequecy, (e.g. power management features are not used), the sum of PCPU USED% for two PCPUs on the same core would be less than 100%. So, the average PCPU USED(%) won't be higher than 50%.

Q: Why is average CPU usage in vSphere client ~100%, but, average "PCPU USED(%)" in esxtop is ~50%?

A: Same as above. It is likely due to hyper-threading. The average CPU usage in vSphere client is deliberately doubled when hyper-threading is used; while esxtop does not double the average "PCPU USED(%)", which would otherwise mean the average USED% of all the cores.

正确解答:

Open ESXTOP and then expand the GID for a VM. When you do, you will see 4 “common” worlds for the Machine plus 1 world for each CPU. So in this exibit, FileServer01 has 12 worlds: 4 we know are common, so the other 8 must be for vCPUs. BTW, the 4 common worlds are: vmx, vmast, vmx-vthread, and vmx-mks while the CPUs are each listed as vmx-vcpu-0, -1, -2, etc. Also in the exibit, all the other VM’s only have 1 vCPU.

vmware中如何检查cpu的使用状况-一个考题引发的思考的更多相关文章

  1. Java中把一个对象的值复制给另外一个对象引发的思考

    Spring生态在Java项目中被广泛应用,从架构到技术应用再到常用的基本功能,Spring给我们的开发带来了很大的便利.今天翻到项目中导出报表功能的时候,发现经常复制对象的方法: BeanUtils ...

  2. cat /proc/cpuinfo 引发的思考--CPU 物理封装-物理核心-逻辑核心-超线程之间关系

    CPU的物理封装,一个物理封装使用独立的一个CPU物理插槽,共享电源和风扇: CPU物理核心:在一个物理封装中封装了多个独立CPU核心,每一个CPU核心都有自己独立的完整硬件单元. CPU逻辑核心:一 ...

  3. CentOS 7 在vmware中的网络设置

    一环境说明 二centos在vmware中的安装 三NAT网络设置 四设置固定IP 1修改网卡配置说明 2修改etcresolvconf 实现域名解析 五设置防火墙iptables 1 centos安 ...

  4. 如何在VMware中安装Windows Phone SDK 8.0 (支持模拟器调试)

    相信很多开发者目前的系统还是Win7或Mac,一般不会为了开发某个程序而重装系统,所以我们就需要用到VMware这类的虚拟机来模拟预期的开发环境.在开始介绍前,给大家说明下我当前的软硬件环境,本文所讲 ...

  5. 解决在VMware中安装64位系统时“此主机具有虚拟化支持能力的,但虚拟化技术被禁用”的方法

    您已经配置此虚拟机使用64位客户操作系统.然而,64位操作系统不可用.此主机具有虚拟化支持能力的,但虚拟化技术被禁用.这通常是因为虚拟化技术已经在BIOS /固件设置或禁用或主机没有权限改变此设置. ...

  6. VMware 中安装KVM,模块不加载

    # yum -y install qemu-kvm libvirt virt-install bridge-utils 通过以上命令在VMWare中centos7安装KVM模块 安装后使用 #lsmo ...

  7. vmware中安装centos 6.7

    centos 6.7 软件下载地址:http://b.mirrors.lanunion.org/CentOS/6.7/isos/i386/ 引用:http://www.cnblogs.com/sees ...

  8. VMware中安装CentOS7网络配置静态IP地址,常用配置和工具安装

    VMware中安装CentOS7网络配置静态IP地址,常用配置和工具安装在阿里云开源镜像地址下载镜像Index of /centos/7.2.1511/isos/x86_64/http://mirro ...

  9. SQL中如何检查死锁

    SQL中如何检查死锁 编写人:CC阿爸 2014-6-15 在日常SQL数据库的操作中,SQL偶尔会出现表被死锁的问题.比如: 在执行事务时,突然中止事务.系统肯定会锁表. 大批量数据操作时,由于网络 ...

随机推荐

  1. hdu3436 splaytree树模拟队列+离散化缩点

    数据较大,需要先把每个top不会操作到的段缩成一个点,记录其开始和结束的位置,和top能操作到的点一起建立一颗伸展树模拟 然后就是普通的队列模拟操作 /* 不会被top操作到的区间就缩点 通过spla ...

  2. appium自动化测试之元素定位

    方法一 使用SDK中附带的uiautomatorviewer来定位 在SDK安装目录下的tools下有个uiautomatorviewer.bat批处理文件点击运行 运行后(注意appium desk ...

  3. 20165203 《网络对抗技术》week1 Kali的安装与配置

    20165203 <网络对抗技术>week1 Kali的安装与配置 本人感觉Kali可以做很多有意思的事情,下面是本人的Kali的安装过程. 安装过程 光盘映像文件的下载 登录官网,选择下 ...

  4. [转] HTML5 FormData 方法介绍以及实现文件上传

    XMLHttpRequest 是一个浏览器接口,通过它,我们可以使得 Javascript 进行 HTTP (S) 通信.XMLHttpRequest 在现在浏览器中是一种常用的前后台交互数据的方式. ...

  5. openstack基础环境准备(一)

    一.环境介绍 操作系统 ip地址 主机名 服务 centos7.5 192.168.56.11 linux-node1 控制节点 centos7.5 192.168.56.12 linux-node2 ...

  6. 关于C#资源文件的相关操作

    关于资源文件的相关操作. //1.比较常见的有获取资源文件对应的文件流,然后转换到相对应的文件 //比较典型的做法是通过代码程序集加载指定资源 //如下通过Assembly的静态方法GetExecut ...

  7. QT学习之windows下安装配置PyQt5

    windows下安装配置PyQt5 目录 为什么要学习QT 命令行安装PyQt5以及PyQt5-tools 配置QtDesigner.PyUIC及PyRcc 为什么要学习QT python下与界面开发 ...

  8. Session失效后所有Ajax请求跳转登录地址

    当登录的Session失效后,采用ajax请求数据时会没有反应,这时候应该自动跳转到登录页面,让用户重新登录. 全局配置以下可实现 $(function() { $.ajaxSetup({ compl ...

  9. 洛谷.3355.骑士共存问题(最小割ISAP)

    题目链接 一个很暴力的想法:每个点拆点,向不能同时存在的连边 但是这样边太多了,而且会有很多重复.我不会说我还写了还没过样例 我们实际就是在做一个最大匹配.考虑原图,同在黄/红格里的骑士是互不攻击的, ...

  10. [HihoCoder1398]网络流五·最大权闭合子图

    题目大意:有$N$项活动$M$个人,每个活动$act_i$有一个正的权值$a_i$,每个人$stu_i$有一个负的权值$b_i$.每项活动能够被完成当且仅当该项活动所需的所有人到场.如何选择活动使最终 ...