VMware vSphere

 View Only
  • 1.  Virtual CPU question

    Posted Feb 15, 2011 12:52 AM

    Hi, I am relatively new to VMs, but have been playing around with them for the past 6 months or so. I have an ESXi host that's running 4 guest VM, and I'm having trouble understanding how the host is allocating CPU to the guest servers.

    One of the guests is a newly installed Exchange 2010 Server on 2008 R2. In this guest OS, the windows task manager was showing that the CPU was maxed out quite a bit. However, when I look at the summary tab of the host, it shows only half CPU usage. I thought the host was supposed to allocate as much as needed, but to me it seems like the host has more that it's not giving to the guest. So after I saw this I configured the guest to have a 2nd virtual CPU, but then I have read that this is not recommended. I also set the CPU shares to high for this guest. I didnt set a reservation, but wondering if I should? I reserved it 8GB of memory, so that doesnt seem to be an issue. Even with the 2nd virtual CPU, task manager still shows the dual virtual CPUs get maxed out sometimes, and the server can act pretty slow when I'm trying to configure it, however the usuage on the host still seems low.

    I guess I am confused, I thought the host was supposed to automatically expand the amount of resources a guest needs so you shouldnt really ever run out unless the host itself is maxed out. Can somebody please explain to me the best way to configure this so this exchange box gets all the cpu it needs?

    Thanks!



  • 2.  RE: Virtual CPU question
    Best Answer

    Posted Feb 15, 2011 01:23 AM

    Hi,

    The way it works is that you have a server with 1 quad core cpu no hyper threading. This would present 4 cores to vmware to use. 4 cores = 4 virtual cpu's to use at a relaxed rate. If you were to add more that 4 virtual cpu's to all your virtual machines, you would be oversubscribing and basically your virtual machines will start queuing for available CPU time. You can measure this with the CPU wait time performance indicator.

    When you set a reservation, let's say 1000Mhz to a virtual machine, that means there will always be 1000Mhz available to that machine from the total pool of available CPU MHz.

    1 virtual CPU for an Exchange 2010 machine is by far not enough cpu power. You would want to allocate a few.

    But why you are seeing int he guest machine 100% utilization is because you've only allocated 1 vcpu to the vm, therefore it is only using 1 core from the cpu. If you have a quad core cpu you would probably see the ESXi host utilization at around 25%

    Hope this clears it up for you



  • 3.  RE: Virtual CPU question

    Posted Feb 15, 2011 01:27 AM

    Also just to add to this, there could be a bottleneck at the local hard drives. As this is the usualy case for running multiple vm's on the one host using local hard disks.

    Another thing to add is that if the vm's are using more memory that your host physically has, it will start using your hard drive for memory ballooning, then you'll really see things slow down :smileyhappy:



  • 4.  RE: Virtual CPU question

    Posted Feb 15, 2011 01:54 AM

    As the other poster has pointed out the VM can only fully utilize the resources in which you have allocated.  If you allocate 1 vCPU then you have the ability to max out one CPU.    Also when changing shares please note that shares only come into play when the physical ESX host is running out of resources and there is contention for resources. 



  • 5.  RE: Virtual CPU question

    Posted Feb 15, 2011 06:33 PM

    Thanks for the replies, they are very helpful!

    To be more specific, we are a small biz, so my exchange box only has 25 users. Also, my host has 2x dual core 3.2GHz processors, so 4 cores all together. So you guys are saying that when I allocate vcpus, it's doing a one to one mapping of vcpus to actual cpu cores? Meaning if I leave the exchange vm at the deault of 1vcpu, it only has 1 physical core and 3.2GHz that it can utilize at all times? And likewise if I allocate 2 vcpus to the exchange box, then the other 3 vm's are fighting between 2 cores?

    So why do people say its not recommended to allocate more than 1 vpcu to a vm, when its obvious that most servers need more than a single core?

    So whats the difference between assigning 2 vcpu's, or 1 vpcu and setting a reservation for 6.4GHz?

    Sorry for all the questions, just want to make sure I understand this properly. Thanks for the help!



  • 6.  RE: Virtual CPU question

    Posted Feb 15, 2011 06:37 PM

    The VM's are scheduled on a core by the vmkernel when it has some processing to perform.  When allocating more than one virtual cpu it has to schedule both of the machines and therefore you have a higher chance of machines waiting to be scheduled.    With each release of vSphere the scheduling of multiple virtual cpus gets better so having 2 isn't as bad as it used to be.   I highly recommend reading the CPU scheduling whitepapers to gain a better understand of how CPU is handled in the virtual environment.

    As far as your resevation if you only assign one CPU then the VM can only use one CPU.  That means your limit would be 3.2 or whatever your processor is.  



  • 7.  RE: Virtual CPU question

    Posted Feb 15, 2011 07:11 PM

    I believe I might be able to provide a tad bit of incite of why only use one vcpu per standard vm. Most tasks that run on computers are single threaded by nature and will only take advantage of a single core. The os will offload work to another core if it is available but your dedicated application will still only be able to take advantage of one core. So you are basically creating more work for your esx server by giving a vm more more than one vcpu. There are applications that DO take advantage of multiple cpus, such as Exchange and SQL. With these applications it is recommended to give two+ vcpus to balance out needed performance with resource contention.

    As such, as more computers are having multiple cores by default and more programers are taking advantage of the extra cores for work this may change in the future as more applications become truly multi-threaded. Basicaly I was told to use your best judgment for how many cpus and how much ram to allocate, but best practice is to start with 1 vcpu and 1 gig of ram and then bump up as needed. 2008r2 allows you to add more ram and I believe another cpu while the vm is running. I do not know if you can remove them without powering down, so be careful in your allocations if you bump them.

    If you have 4 cores to work with, you could logically create a vm with up to 4 vcpu but it will likely not run well with the other vms needing resources too. It is considered best practice to not allocate more vcpus than cores your esx host has as this creates resource contention as someone else had said. I

    If your exchange server needs more resources and your other vms are not doing anything to intensive you would likely be OK adding a third vcpu to your vm but you will be creating contention. If it bad enough, ALL vms will start to perform poorly.

    Hoping for the best,