VMware Cloud Community
Aravindakumar
Contributor
Contributor

Resource allocation

Is it recommended to use the resource allocation options ( CPU Reservation, Memory Reservation) to adjust resources between virtual servers in the same host?

Tags (2)
0 Kudos
20 Replies
weinstein5
Immortal
Immortal

Only when nesessary - you can run into many issues if you do not know how these impact your host use of those resources - 

If you find this or any other answer useful please consider awarding points by marking the answer correct or helpful
0 Kudos
Aravindakumar
Contributor
Contributor

Thanks, what is the recommended approach if we would like to adjust resources between virtual servers within a host?

0 Kudos
depping
Leadership
Leadership

Use Shares... shares are only used when there is contention. limits and reservations are always applied.

0 Kudos
Aravindakumar
Contributor
Contributor

Thanks, If i have a host with a quad core 8 GB and I want to create 2 VMs. then I create two VMs both having 3 cores and 7 GB ( leaving 1 core and 1GB for host usage) and just set the Share Level to High for one and Low for other and do vice versa when I want to reverse,

Is my understanding correct?

0 Kudos
weinstein5
Immortal
Immortal

A couple of comments -

  • start with a mnimum number of CPUs and add CPUs if performance is not satisfactory -  not knowing the workload but I think you will find you VM will be fine with a single vCPU or at most 2
  • giving a VM a vCPU does not dedicate a core to that vM - the vmkernel will schedule the vCPUs to a core when the VM needs it and over the years this scheduling has gotten much better - in fact you came overcommit the number of cores - with vSphere 6-8 vCPU to a physical core is a conservative ration
  • Shares come into play when there is contention - so if there are plenty of CPU cycles the shares will not be used -

To answer your question yes it will work but you will be underutilizing your ESXi host -

If you find this or any other answer useful please consider awarding points by marking the answer correct or helpful
0 Kudos
rickardnobel
Champion
Champion

Aravindakumar wrote:

Thanks, If i have a host with a quad core 8 GB and I want to create 2 VMs. then I create two VMs both having 3 cores and 7 GB ( leaving 1 core and 1GB for host usage)

If you mean that both VMs get 7 GB of RAM each then this will not be good. If not having a real good reason it will not make much sense to configure such high RAM overcommit directly.

My VMware blog: www.rickardnobel.se
0 Kudos
Aravindakumar
Contributor
Contributor

Anyway these VMs are controlled by the Share levels right.

If both the VMs are at Share Level Normal , both will get equal amount of Memory say 3.5GB when needed.

I would like to understand that what makes it wrong to do so?

0 Kudos
weinstein5
Immortal
Immortal

There is nothing wrong with what you propose since Shares will only come into play if there is a shorttage of CPU Cycles or Memory - If there is contention the memory will be divided based on the shares - how the resource is allocated based on shares works like this - assigning Low, Normal and High assignes a share for example for CPU it Corresponds to 500 for low, 1000 for Normal and 2000 for high  so with you example if there is contention for CPU the CPU cycles will be divided as follows - with Low and High assigne you will have a pool of 2500 share pool - this will divide the cycles as follows 2000/2500 or 80% of the cycles will be given to the VM with the HIGH share setting while 20% will be given to the VM with Low share setting - If there are plenty if cycles avalable each VM will get what it needs-

Memory works the same way except the allocation of the shares is little different - low the shares assiged is 5 x the number of MB of memory assigned to the VM, Normal 10 x the number of MB assigned to the VM and Hish is 20 times the amount of MB assigned to the VM

For more information check out page 13 of http://pubs.vmware.com/vsphere-50/topic/com.vmware.ICbase/PDF/vsphere-esxi-vcenter-server-501-resour...

If you find this or any other answer useful please consider awarding points by marking the answer correct or helpful
0 Kudos
rickardnobel
Champion
Champion

Aravindakumar wrote:

If both the VMs are at Share Level Normal , both will get equal amount of Memory say 3.5GB when needed.

I would like to understand that what makes it wrong to do so?

In my opinion it is often not a good idea to create VMs with 14 GB of vRAM with only 8 GB physical available. Memory works in a much different way than CPU, where the CPU cycles are very easy for the vmkernel to divide between the VMs, but memory management is done by "harder" methods (page sharing, ballooning, compression and swapping). This impacts the guest VMs a lot more than CPU handling - where I totally agree that shares is a very good thing to use.

If you give both your VMs 7 GB of vRAM each then the internal Guest Operating Systems will assume that specific amount of memory is in fact available and will act from that. Often modern operating systems try to fill all the RAM they have for maximum performance. The problem here is that your physical host could never give this RAM to your VMs and the vmkernel would likely be forced to use aggressive ballooning and swapping with reduced performance as result.

My VMware blog: www.rickardnobel.se
0 Kudos
Aravindakumar
Contributor
Contributor

In that case setting 3.5 GB VM Memory and 3.5 GB in ReservationMemory in Resource Allocation Settings will be a good option for each VM, am I correct?

0 Kudos
rickardnobel
Champion
Champion

Aravindakumar wrote:

In that case setting 3.5 GB VM Memory and 3.5 GB in ReservationMemory in Resource Allocation Settings will be a good option for each VM, am I correct?

Without knowing what your specific guests are and their purpose (if one VM have a system that needs more RAM than the other?) then I think in general a 3.5 GB vRAM assignment would be good.

However, you should not set any Reservation in this case. It would not do any good and as Weinstein5 wrote earlier this could create other issues.

My VMware blog: www.rickardnobel.se
0 Kudos
Aravindakumar
Contributor
Contributor

Ok I understand , it is better to just set the vCPU, Memory settngs at VM level and let the resource allocation settings to be default.

And when I would like to manage resources between VMs in  the same host, is it better to modify the VM vCPU , Memory  settings after VM power off or adjust the resource allocation shares?

0 Kudos
rickardnobel
Champion
Champion

Aravindakumar wrote:

Ok I understand , it is better to just set the vCPU, Memory settngs at VM level and let the resource allocation settings to be default.

In my opinion: yes. Set the vCPU and vRAM to a reasonable level. If you only will run two VMs at this host then you could afford to give them more vCPUs - if there are a system inside the VMs that will be able to actually use the cpu cycles.

For vRAM this 3.5 GB assignment and no other settings will make the VM guest operating systems able to handle all memory management internally and optimize for this specific amount.

And when I would like to manage resources between VMs in  the same host, is it better to modify the VM vCPU , Memory  settings after VM power off or adjust the resource allocation shares?

That will depend on the situation. If you have a specific need to alter something just for a certain day or so, then you could modify the resource allocation settings, but for long time it is best to make sure they have a correct basic assignment.

In your situation you will likely never run out of CPU if you only plan to use these two guests, so I do not think you need to worry about that either.

My VMware blog: www.rickardnobel.se
0 Kudos
Aravindakumar
Contributor
Contributor

My situtation is that I need to adjust the resources between the VMs atleast once every day. VM1 need to use 75% of host resources and VM2 need to use 25% of host resources during first half of the day and during the second half of the day it has to be vice versa.

What would be recommended settings for this situation considering a host of quad core and 8GB Memory?

0 Kudos
rickardnobel
Champion
Champion

Aravindakumar wrote:

VM1 need to use 75% of host resources and VM2 need to use 25% of host resources during first half of the day and during the second half of the day it has to be vice versa.

When you say resources, what do you mean specifically?

My VMware blog: www.rickardnobel.se
0 Kudos
Aravindakumar
Contributor
Contributor

I meant VM1 needs to use 2 Cores and 6 GB memory while VM2 needs to use 1 core and 1 GB during the first half of the day and during the second half of the day VM1 needs to use 1 Core and 1GB memory while VM2 needs to use 2 Cores and 6GB.

0 Kudos
rickardnobel
Champion
Champion

The vCPU cores will not be a problem, when the VM does not need them they are just unused and you have plenty of them.

For the memory it is more tricky. So your application needs 6 GB of RAM at different times of the day? The best way would of course be to buy 4 GB of physical RAM and install into the host.

You could try to give them 6 GB of vRAM each and hope that the Vmkernel could force the outer VMs memory away when it is more idle during the day. Shares and Reservations would not help you in this situation.

My VMware blog: www.rickardnobel.se
0 Kudos
Aravindakumar
Contributor
Contributor

If I run a script say PowerCLI script at a specific time evry day and adjust the VM Memory in these 2 VMs , I am afford to do a VM Power Off during that time. Can I consider that as one solution?

0 Kudos
rickardnobel
Champion
Champion

Aravindakumar wrote:

If I run a script say PowerCLI script at a specific time evry day and adjust the VM Memory in these 2 VMs , I am afford to do a VM Power Off during that time. Can I consider that as one solution?

That might be possible, but is this a production environment you are building? Are you sure you can not upgrade to host to 12 or 16 GB of physical RAM?

My VMware blog: www.rickardnobel.se
0 Kudos