首页 > 系统相关 >vSphere5.9.1.管理内存和CPU分配

vSphere5.9.1.管理内存和CPU分配

时间:2024-08-20 19:38:55浏览次数:13  
标签:shares CPU host vSphere5.9 内存 memory vms cpu

第一部分

管理内存和cpu分配

关联vm内存

虚拟机感觉自己拥有4g的内存,并且最多不会使用超过4g的物理内存.我们可以超额的关联内存给vm,例如:esxi主机的物理内存只有8g,但是我们可以给三个vm分配4g内存.

esxi四大高级内存控制技术

1.page sharing(透明的页面共享)

the first memory-management technology vmware wsxi uses is transparent page sharing,in which identical memory pages are shared among vms to reduce the lotal number of memory pages needed.the hypervisor computes hashes of the contents of memory pages to identify pages that contain identical memory.if a hash match is found,a full comparison of the matching memory pages is made in order to exclude a false positive.once the pages are confirmed to be identical,the hypervisor will transparently remap the memory pages of the vms so they are sharing the same physical memory page.this reduces overall host memory consumpton.(相同内存的页面不同的vm使用一个vm读取,其他vm访问这台读取页面的vm)

2.ballooning

ballooning involves the use of a driver-referred to as the balloon driver-installed into the guest os.this driver is part of vmware tools and gets installed when vmware tools are installed.once installed into the guest os,the balloon driver can respond to commands from the hypervisor to reclaim memory from that particular guest os.the balloon driver does this by requesting memory from the guest of-a process calling inflating-and then passing that memory back to the hypervisor for use by other vms.when the memory pressure on the host passes,the balloon driver will deflate,or return memory to the guest os.(需要安装vmware tools,强迫主机更少使用内存,让急需内存的vm来使用)

3.swapping

a.guest os swapping

b.hypervisor swapping

hypervisor swapping means that esxi is going to swap memory pages out to disk in order to reclaim memory that is needed elsewhere.esxi's swapping takes place without any regard to whether the pages are being actively used by the guest os.as a result,and due to the fact that disk response times are thousands of times slower than memory response times,guest os performance is severely impacted if hypervisor swapping is invoked.it is for this reason that esxi won't invoke swapping unless it is absolutely necessary.(虚拟内存,影响整体性能,使用硬盘空间来实现内存,降低效率)

4.memory compression(内存压缩)

when an esxi host gets to the point that hypervisor swapping is necessary,the vmkernel will attempt to compress memory pages and keep them in rem in a compressed memory cache.pages that can be successfully compressed by at least 50 percent are put into the compressed memory cache instead of being written to disk and can then be recovered much more quickly if the guest os needs that memory page.memory compression can dramatically reduce the number of pages that must be swapped to disk and thus can dramatically improve the performance of an esxi host that is under strong memory pressure.compression is invoked only when the esxi host reaches the point that swapping is needed.(内存压缩,节约内存空间,压缩到50%)

配置内存关联

预留

限制

共享

配置内存预留

1.vm能够请求的最大内存数量就是配置的数量

2.预留决定了这个vm至少能够使用多少物理内存,其余的可能使用swap,也可能使用物理内存

配置内存限制

the limit sets the actual limit on how much physical ram may be utilized by that virtual machine.

let's now change the limit on this virtual machine from the unlimited default setting to 768mb.

1.the virtual machine is configured with 1024mb of ram,so the guest operating system running inside that virtual machine believes that it has 1024mb of ram available to use.

2.the virtual machine has a reservation of 512mb of ram,which means that the esxi host must allocate 512mb of physical ram to the virtual machine.this ram is guaranteed to this virtual machine.

3.assuming the esxi host has enough physical ram installed and available,the hypervisor will allocate memory to the virtual machine as needed up to 768mb (the limit).upon reaching 768mb,the balloon driver kicks in to prevent the guest operating system from using any more memory.when the guest operating system's memory demands drop below 768mb,the balloon driver deflates and returns memory to the guest.the effective result of this behavior is that the memory that the guest operating system uses remains below 768mb(the limit).

4.the 256mb "gap" between the reservation and the limit may be supplied by either physical ram or vmkernel swap space.esxi will allocate physical ram if it is available.

配置份额值

shares(份额值) are a way of establishing a priority setting for a virtual machine requesting memory that is greater than the virtual machine's reservation but less than its limit.

实例一:

物理主机内存2000m

vm1 预留500m闲置2000m份额值1000

vm2 预留500m闲置2000m份额值1000

vm1 实际得到的物理内存为1000m

vm2 实际得到的物理内存为1000m

实例二:

物理主机内存2000m

vm1 预留500m闲置2000m份额值2000

vm2 预留500m闲置2000m份额值1000

vm1 实际得到的物理内存为1166m

vm2 实际得到的物理内存为833m

vm cpu介绍

how could a virtual machine emulate a cpu?the answer wa "no emulation."think about a virtual system board that has a "hole" where the cpu socket goes-and the guest operating system simply looks through the hole and sees one of the cores in the host server.

多cpu调度介绍:

the vmkernel simultaneously schedules cpu cycles for multi-vcpu virtual machines.this means that when a dual-vcpu virtual machine places a request for cpu cycles,the request goes into a queue for the host to process,and the host has to wait until there are at least two cores or hyperthreads(if hyperthreading is enabled)with concurrent idle cycles to schedule that virtual machine.a relaxed coscheduling algorithm provides a bit of flexibility in allowing the cores to be scheduled on a slightly skewed basis,but even so,it can be more difficult for the hypervisor to find open time slots on at least two cores.this occurs even if the virtual machine needs only a few clock cycles to do some menial task that could be done with a single processor.建议在开始创建vm的时候,都使用一个vcpu.

cpu affinity介绍

in addition to shares,reservations,and limits,vsphere offersa fourth option for managing cpu usage:cpu affinity.cpu affinity allows an administrator to statically associate a vm to a specific physical cpu core.cpu affinity is generally not recommended;it has a list of rather significant drawbacks;(多核cpu可以使用任何一个核cpu)

cpu affinity技术的限制

1.cpu affinity breaks vmotion.(不能做vmotion)

2.the hypervisor is unable to load-balance the vm across all the processing cores in the server.this prevents the hypervisor's scheduling engine from making the most efficient use of the host's resources.(可以在所有cpu做负载均衡,任何核心都可以为vm提供服务)

3.because vmotion is broken,you cannot use cpu affinities in a cluster where vsphere drs isn't set to manual operation.

配置cpu关联

预留

限制

共享

实例接收cpu关联

实例环境介绍:

1.the esxi host includes dual,single-core,3 ghz cpus.

2.the esxi host has one or more vms

scenario 1 the esx host has a single vm running.the shares are set at the defaults for the running vms.will the shares value have any effect in this scenario?no. there's no competition between vms for cpu time.

scenario 2 the esx host has two idle vms running.the shares are set at the defaults for the running vms.will the shares values have any effect in this scenario?no. there's no competition between vms for cpu time because both are idele.

scenario 3 the esx host has two equally busy vms running(both requesting maximum cpu capacity).the shares are set at the defaults for the running vms.will the shares values have any effect in this scenario?no. again,there's no competition between vms for cpu time,this time because each vm is serviced by a different core in the host.

scenario 4 to force contention,both vms are configured to use the same cpu by setting the cpu affinity.the esxi host has two equally busy vms running(both requesting maximum cpu capacity).this ensures contention between the vms.the shares are set at the defaults for the running vms.will the shares values have any effect in this scenario? yes!but in this case,because all vms have equal shares values,each vm has equal access

scenario 5 the esxi host has two equally busy vms running (both requesting maximum cpu capacity with cpu affinity set to the same core).the shares are set as follows;vm1 is set to 2000 cpu shares,and vm2 is set to the default 1000 cpu shares.will the shares values have any effect in this scenario?yes. inthis case,vm1 has double the number of shares that vm2 has.this means that for every clock cycle that vm2 is assigned by the host,vm1 is assigned two clock cycles,stated another way,out of every three clock cycles assigned to vms by the esxi host,two are assigned to vm1,and one is assigned to vm2.

scenario 6 the esxi host has three equally busy vms running(each requesting maximum cpu capabilities with cpu affinity set to the same core).the shares are set as follows;vm1 is set to 2000 cpu shares,and vm2 and vm3 are set to the default 1000 cpu shares.will the shares values have any effect in this scenario? yes.inthis case,vm1 has double the number of shares that vm2 and vm3 have assigned.this means that for every two clock cycles that vm1 is assigned by the host,vm2 and vm3 are each assigned a single clock cycle.stated another way,out of every four clock cycles assigned to vms by the esxi host,two cycles are assigned to vm1,one is assigned to vm2,and one is assigned to vm3.you can see that this has effectively watered down vm1's cpu capabilities.

scenario 7 the esxi host has three vms running.vm1 is idle while vm2 and vm3 are equally busy(each requesting maximum cpu capabilities,and all three vms are set with the same cpu affinity).the shares are set as follows;vm1 is set to 2000 cpu shares,and vm2 and vm3 are set to the deufalt 1000 cpu shares.will the shares values have any effect in this scenario? yes.but in this case vm1 is idle,which means it isn't requesting any cpu cycles.this means that vm1's shares value is not considered when apportioning the host cpu to the active vms.in this case,vm2 and vm3 would equally share the host cpu.cycles because their shares are set to an equal value.

标签:shares,CPU,host,vSphere5.9,内存,memory,vms,cpu
From: https://www.cnblogs.com/smoke520/p/18370168

相关文章

  • vSphere5.9.4.网络IO控制
    第四部分网络i/o控制网络i/o控制介绍networkresourcepoolthatallowsyoutocontrolnetworkutilization.usingnetworkresourcepools-towhichareassignedsharesandlimits-youcancontroloutgoingnetworktraffic.thisfeatureisreferredtoasvspherenetw......
  • vSphere5.9.5.存储IO控制
    第五部分存储i/o控制存储i/o介绍(1)thereisametric,however,thatvspherecanusetohelpdeterminetheutilizationofstorage.thatmetricislatency.usinglatencyasthemetrictodetectcontention,vspherecanoffershares(toestablishprioritywhencontent......
  • 国产海光CPU平台兼容性指南-基础软件分册-20231013(附各系统下载链接)
    目录声明一、操作系统 二、虚拟化和云2.1 虚拟化和云2.2虚拟机上的操作系统2.2.1 VMwarevSphere上的虚拟机操作系统2.2.2  KVM上的虚拟机操作系统2.2.3  WindowsHyper-V上的虚拟机操作系统2.2.4  VirtualBox上的虚拟机操作系统三、分布式存储 四、......
  • 深入理解 Go 语言原子内存操作
            原子内存操作提供了实现其他同步原语所需的低级基础。一般来说,你可以用互斥体和通道替换并发算法的所有原子操作。然而,它们是有趣且有时令人困惑的结构,应该深入了解它们是如何工作的。如果你能够谨慎地使用它们,那么它们完全可以成为代码优化的好工具,而不会增加......
  • Java数组02:数组内存分析、三种初始化方式及特点
    本节内容视频链接:Java数组03:三种初始化及内存分析_哔哩哔哩_bilibilihttps://www.bilibili.com/video/BV12J41137hu?p=53&vd_source=b5775c3a4ea16a5306db9c7c1c1486b51.数组内存分析堆:存放new的对象和数组;可以被所有线程共享,不会存放别的对象引用;栈:存放基本变量类型,会包含......
  • C++ 获取Linux 服务器CPU占用率+内存空闲率(亲测绝对可以运行)
    转自:C++获取Linux服务器CPU占用率+内存空闲率(亲测绝对可以运行)-远征i-博客园(cnblogs.com)代码来自网络,部分修改,亲测绝对可用C++:#include<stdio.h>#include<stdlib.h>#include<string.h>#include<iostream>#include<unistd.h>usingnamespacestd;type......
  • C/C++语言基础--指针三大专题详解2(指针与数组关系,动态内存分配,代码均可)
    本专栏目的更新C/C++的基础语法,包括C++的一些新特性前言指针是C/C++的灵魂,和内存地址相关联,运行的时候速度快,但是同时也有很多细节和规范要注意的,毕竟内存泄漏是很恐怖的指针打算分三篇文章进行讲解,本专题是二,介绍了指针和数组的关系、动态内存如何分配和释放等问题专题......
  • 内存(动态开辟)———C语言
    内存管理: 1.C语言运行时的内存分配2.static关键字1.修饰变量局部变量:        <1>在编译的过程中,会在数据区为该变量开辟空间,如果代码中未对其进行初始化,则系统默认初始化为0。        <2>用static修饰的局部变量,会延长局部变量的生命周期#include<s......
  • CPU的功能和基本结构
    1.CPU的功能①指令控制完成取指令、分析指令和执行指令的操作,即程序的顺序控制。 ②操作控制一条指令的功能往往是由若干操作信号的组合来实现的。CPU管理并产生由内存取出的每条指令的操作信号,把各种操作信号送往相应的部件从而控制这些部件按指令的要求进行动作。 ③......
  • 加固显控终端:兼容飞腾、龙芯、瑞芯微等国产CPU处理器的100%国产化加固显控终端
        加固显控终端通常是指对显示控制终端进行物理和逻辑上的增强,以提高其在恶劣环境下的稳定性和安全性。这种类型的终端常见于工业、军事或其他需要高可靠性的环境中。①基于飞腾FT2000/4、D2000、E2000Q;龙芯LS3A4000、LS3A500、LS2K1000;瑞芯微RK3588等处理器;②......