Loading

如何理解CPU steal time

细心的小伙伴可能会发现GNU top命令有个 st 的性能指标,通常这个指标都为0或者比较低我们很少关注。但它确实是一个值得我们关注的指标。st 指标一般出现在虚拟机上,物理机和版本比较老的Linux 系统不显示该指标。下面我们就简单了解一下。

怎么查看CPU Steal Time?

st即 Steal Time, top命令 可以很容易地检测guest VM 实例上的 CPU Steal Time。窃取时间显示在第 3 行末尾的 top 输出中,其中存在%Cpu(s),如下面的截图所示(它是末尾的值,标记为st。)这个示例中我把两个核心的CPU Stell Time 百分比都显示出来了,它们都为 0 ,top默认只显示综合指标。

CPU Steal Time

监控系统上CPU Steal Time

zabbix CPU Steal Time

CPU Steal Time 的定义

From ibm :

Steal time is the percentage of time a virtual CPU waits for a real CPU while the hypervisor is servicing another virtual processor.

From opensource.com :

CPU steal time is defined in the [GNU **top**](https://en.wikipedia.org/wiki/Top_(software)) command as "time stolen from [a] VM by the hypervisor." CPU steal time occurs when a hypervisor process and a guest instance are trying to utilize the same hypervisor physical core (pCPU) at the same time. This results in less processor time available to the guest's virtual CPU (vCPU) and performance degradation for the guest.

通俗来讲,我们的虚拟机(VM)会与虚拟环境的宿主机上的多个虚拟机实例共享物理物理CPU资源,也就是共享CPU时间切片。如果多个虚机竞争物理CPU资源,则某些 guest 主机可能在某段时间内需要等待 pCPU 作出响应,这个等待的时间就是 Steal time。

在当今的虚拟化环境(如公有云和私有云)中,guest 实例可能会在以下几种情况下体验性能 CPU 窃取时间:

  • 虚拟机管理程序(hypervisor)的超额分配和具有高 CPU 利用率的多个guest VM 的 vCPU 正在相同的 pCPU 上运行。
  • guest vCPU 及其仿真器线程被固定到同一个 pCPU,导致 vhost 进程在处理 I/O 时从guestvCPU 窃取 CPU 时间。
  • 虚拟机监控程序进程(如监控、日志记录和 I/O 进程)同时使用一个 pCPU,而guest VM vCPU 也在使用该 pCPU。

如何判断 st

如果你的应用部署虚拟环境, steal time就是你想要关注的性能指标之一。 如果这个指标的数值很高,那么说明机器状态非常糟糕。大体判断标准:

CPU窃取时间低:如果您的 CPU 窃取时间低于 10%,则无需担心。您的应用程序应该可以顺利运行。

CPU窃取时间相对较高:您的 CPU 窃取时间远远超过 10%,持续约 30 分钟。当这种情况发生:

1、迁移虚拟机到另一台物理机器上面。
2、如果steal time维持在很高的数值, 那么增加CPU资源配额。
3、对性能要求高的应用可购买独享型云主机。

更多信息

https://opensource.com/article/20/1/cpu-steal-time

https://blog.appsignal.com/2021/09/15/cpu-steal-time-a-crucial-metric-for-cloud-servers-and-vms.html

https://blog.leaseweb.com/2020/09/24/understanding-and-interpreting-cpu-steal-time-on-virtual-machines/

posted @ 2022-02-14 19:31  五月的麦田  阅读(1494)  评论(0编辑  收藏  举报