找回密码
 register

QQ登录

只需一步,快速开始

[*网络运维*] Proxmox VE (PVE 8.0) 中 CPU 相关选项的作用

[复制链接]

[*网络运维*] Proxmox VE (PVE 8.0) 中 CPU 相关选项的作用

[复制链接]
Waylee

主题

0

回帖

1万

积分

仙帝

积分
10125
Waylee 2024-9-3 13:25 | 显示全部楼层 |阅读模式

马上注册,查看网站隐藏内容!!

您需要 登录 才可以下载或查看,没有账号?register

×
  这是关于 Proxmox VE (PVE 8.0) 中 CPU 相关选项的作用的笔记,可能有错误理解,仅供参考。如果您发现文中有错误,麻烦通过页面右边的邮箱告诉我,谢谢。
001.jpg
一.CPU 权重(CPU units)
官方解释
The second CPU resource limiting setting, cpuunits (nowadays often called CPU shares or CPU weight), controls how much CPU time a VM gets compared to other running VMs. It is a relative weight which defaults to 100 (or 1024 if the host uses legacy cgroup v1). If you increase this for a VM it will be prioritized by the scheduler in comparison to other VMs with lower weight. For example, if VM 100 has set the default 100 and VM 200 was changed to 200, the latter VM 200 would receive twice the CPU bandwidth than the first VM 100.For more information see man systemd.resource-control, here CPUQuota corresponds to cpulimit and CPUWeight corresponds to our cpuunits setting, visit its Notes section for references and implementation details.
  CPU 权重默认数值为 100(在某些旧系统上可能为 1024),此设置决定了这个虚拟机相对同一主机上的其他虚拟机的性能优先级。
  举例:
  [虚拟机 VM ID 100] 的 CPU 权重为 100。
  [虚拟机 VM ID 101] 的 CPU 权重为 200。
  这种情况下,[虚拟机 VM ID 101] 拥有更高的 CPU 权重,它将获得更多的 CPU 资源。
二.CPU 限制(CPU limit)
官方解释
In addition to the number of virtual cores, you can configure how much resources a VM can get in relation to the host CPU time and also in relation to other VMs. With the cpulimit (“Host CPU Time”) option you can limit how much CPU time the whole VM can use on the host. It is a floating point value representing CPU time in percent, so 1.0 is equal to 100%, 2.5 to 250% and so on. If a single process would fully use one single core it would have 100% CPU Time usage. If a VM with four cores utilizes all its cores fully it would theoretically use 400%. In reality the usage may be even a bit higher as QEMU can have additional threads for VM peripherals besides the vCPU core ones. This setting can be useful if a VM should have multiple vCPUs, as it runs a few processes in parallel, but the VM as a whole should not be able to run all vCPUs at 100% at the same time. Using a specific example: lets say we have a VM which would profit from having 8 vCPUs, but at no time all of those 8 cores should run at full load - as this would make the server so overloaded that other VMs and CTs would get to less CPU. So, we set the cpulimit limit to 4.0 (=400%). If all cores do the same heavy work they would all get 50% of a real host cores CPU time. But, if only 4 would do work they could still get almost 100% of a real core each.VMs can, depending on their configuration, use additional threads, such as for networking or IO operations but also live migration. Thus a VM can show up to use more CPU time than just its virtual CPUs could use. To ensure that a VM never uses more CPU time than virtual CPUs assigned set the cpulimit setting to the same value as the total core count.
  这个设置用于配置虚拟机相对于主机 CPU 时间及其他虚拟机的资源获取情况。
  设置 1.0 就等于 100%,相当于可使用 1 个物理核心的 CPU 时间。
  设置 2.5 等于 250%,相当于可使用 2.5 个物理核心的 CPU 时间。
  假设物理机有 12 个物理核心,在 [虚拟机 VM ID 100] 中给他分配了 8 个虚拟核心,但 CPU limit 设置为 5(500%),此时 [虚拟机 VM ID 100] 的 8 个虚拟核心的总性能基本等于 5 个物理核心的性能。
PS:建议设置 CPU limit 的值不要超过物理核心的数量,因为过度分配会影响其他虚拟机和主机的性能。

三.CPU 相关性(CPU Affinity)
官方解释
The third CPU resource limiting setting, affinity, controls what host cores the virtual machine will be permitted to execute on. E.g., if an affinity value of 0-3,8-11 is provided, the virtual machine will be restricted to using the host cores 0,1,2,3,8,9,10, and 11. Valid affinity values are written in cpuset List Format. List Format is a comma-separated list of CPU numbers and ranges of numbers, in ASCII decimal.CPU affinity uses the taskset command to restrict virtual machines to a given set of cores. This restriction will not take effect for some types of processes that may be created for IO. CPU affinity is not a security feature.For more information regarding affinity see man cpuset. Here the List Format corresponds to valid affinity values. Visit its Formats section for more examples.
  CPU 相关性可以限制虚拟机在主机指定的物理核心上运行。
  例如,假设物理机有12个核心(0-12),如果设置了 CPU 相关性为 0-3,8-11,则虚拟机将被限制运行在物理核心 0、1、2、3、8、9、10 和 11。
  CPU 相关性的一些使用场景:
  (1)针对一些对延迟和响应时间有严格要求,避免资源竞争,保持性能稳定。
  (2)为同一台主机上的多个虚拟机设置不同的 CPU 相关性数值,保证虚拟机使用 CPU 资源互不干扰。
  (3)某些应用程序对 CPU 相关性有特定需求。例如一些密集计算的工作负载,通过将虚拟机限制在一组紧密相邻的主机核心上,可以获得更好的数据传输和通信性能。
您需要登录后才可以回帖 登录 | register

本版积分规则

雪舞知识库 | 浙ICP备15015590号-1 | 萌ICP备20232229号|浙公网安备33048102000118号 |网站地图|天天打卡

GMT+8, 2024-12-5 03:17 , Processed in 0.050638 second(s), 8 queries , Redis On.

Powered by XueWu Licensed

Copyright © Tencent Cloud.

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