VMware Cloud Community
Stevenm1
Contributor
Contributor

Question on vcpu allocation

Hi, I'm pretty new to VMware and trying to understand some of the concepts around defining cpu and memory values for new vm's.

We have some application servers which were created with 8vcpu's ( running on HP 12-way hyperthread enabled G7 blades ). Iv'e been monitoring these app servers for a while and they are only averaging 10% CPU usage. It may occasionally peak to 25% for a brief period. I am thinking of reducing the amount of vcpu down to 4 but what is the benefit of doing this?

Is there any harm in keeping the vcpu value at 8 even though it is only averaging 10% usage? From what I understand the VM will only use the amount of cpu it requires so the idle 4 vcpu are not being wasted and are available for other VM's correct? So what is the benefit of reducing this number down to 4?

0 Kudos
7 Replies
rcporto
Leadership
Leadership

The best practices is always start with small number of vCPU and add more only if necessary... giving more vCPU than necessary may degrade performance of VM because it becomes more difficult for the scheduler to coordinate time slots on the physical CPUs.

---

Richardson Porto
Senior Infrastructure Specialist
LinkedIn: http://linkedin.com/in/richardsonporto
0 Kudos
vuzzini
Enthusiast
Enthusiast

Hello Stevenm1,

Let's take an example of a four pCPU host that has four VMs, three with 1 vCPU and one with 4 vCPUs. At best only the three single vCPU VMs can be scheduled concurrently. In such an instance the 4 vCPU VM would have to wait for all four pCPUs to be idle. In this example the excess vCPUs actually impose scheduling constraints and consequently degrade the VM’s overall performance, typically indicated by low CPU utilization but a high CPU Ready figure. With the ESX server scheduling and prioritising workloads according to what it deems most efficient to run, the consequence is that smaller VMs will tend to run on the pCPUs more frequently than the larger overprovisioned ones. So in this instance overprovisioning was in fact proving to be detrimental to performance as opposed to beneficial. Now in more recent versions of vSphere the scheduling of different vCPUs and de-scheduling of idle vCPUs is not as contentious as it used to be. Despite this, the VMKernel still has to manage every vCPU, a complete waste if the VM’s application doesn’t use them..

My recommendation for your current environment would be to reduce the number of vCPU from 8 to 4 as the application utilization of CPU resources is very minimal at the moment, test the application performance and scale it up if required at all.

If you found this or any other answer useful please consider the use of the Helpful or Correct buttons to award points. Sandeep Vuzzini Sr. DevOps Engineer
0 Kudos
Stevenm1
Contributor
Contributor

Thank you for the above answers.

I forgot to ask the same question regarding memory, does over allocating memory have detrimental effect on the VM or other VM's on the ESX? If each of my VM's has 64GB memory but only use 35GB on average is the spare memory avail to other VM's?

0 Kudos
Stevenm1
Contributor
Contributor

Sandeep,

Are you saying cpu scheduling is done on a per vm basis ie: if my vm has 6 vcpu it will need to wait for 6 cores to be available before anything can run?

0 Kudos
MyuFox
Enthusiast
Enthusiast

Topping out at %25 at 8 vCPU? Bring that puppy down to 2 vCPU seriously. Over provisioning is a waste of resources don't do it. vCPU are nothing like physical CPU pCPU and should not be thought of as such. An application that was running on 12 pCPU might be very happy with 1 vCPU. Domain controllers for example only need 1vCPU.

Hyper threading should not be factored when allocating vCPU ever. Doing this will only give headaches when things do not work right. Hyper threading means two threads on a physical core, this core still has the same amount of resources to it. This means the CPU is used more efficiently sure, but not double the resources. For example a 4 core CPU you can run 10 1vCPU VMs a 4 core HT CPU you can run 13 1vCPU VMs. Real numbers vary a lot but HT is commonly 15% increase in performance or so.

Another thing to note is task manger performance counters have no relation to performance counter the ESXi host shows. They are calculated completely different and mean different things despite the names being similar.

http://www.vmware.com/pdf/Perf_Best_Practices_vSphere5.5.pdf  - page 20

Edit:

Forgot to comment on the memory. Do not allocate more memory than what the VM needs. (consumed memory metric is for charge back purposes and should be not be considered when looking at memory performance) You will quickly find that you have all the CPU power and then some but never enough memory. Lower the memory until it is just enough that there isn't very much to no in-guest swapping. The swap metric in ESXi is swapping when restrictions are placed or the host is out of memory. Supper bad for performance and should always be zero for prod VMs.

0 Kudos
vuzzini
Enthusiast
Enthusiast

Hello Stevenm1,

Memory is also a shared resource between the VM's, if memory is over provisioned, the vmkernel will always be busy in utilizing memory management techniques to suffice vm requirements. It is best to allocate memory whatever application is entitled to.

If you found this or any other answer useful please consider the use of the Helpful or Correct buttons to award points. Sandeep Vuzzini Sr. DevOps Engineer
0 Kudos
vuzzini
Enthusiast
Enthusiast

One of the major design goals of the CPU scheduler is fairness. CPU time consumption of virtual machines has to be faithful to the resource specifications like CPU shares, reservations, and limits. The CPU scheduler is based on the proportional share algorithm. The CPU scheduler aims to maximize CPU utilization and world execution efficiency, which are critical to system throughput. The scheduling is usually based on world.

For an example, A virtual machine consists of one or more vCPU worlds on which guest instructions are executed. For example,a 4-vCPU virtual machine has 4 vCPU worlds. There are other worlds associated with the virtual machine that execute management tasks like handling the mouse and keyboard, snapshots, and legacy I/O devices. Therefore, it is theoretically possible that a 1-vCPU virtual machine can consume more than 100% of a processor,although this is unlikely because those management worlds are mostly inactive.

Refer http://www.vmware.com/files/pdf/techpaper/VMware-vSphere-CPU-Sched-Perf.pdf for more information.

If you found this or any other answer useful please consider the use of the Helpful or Correct buttons to award points. Sandeep Vuzzini Sr. DevOps Engineer
0 Kudos