The Late Great Virtual CPU Debate
Summary: Using multiple vCPUs can decrease VM performance. While that concept is counterintuitive, it makes sense, if you think about how CPU resources are doled out.
Do you ever have the situation where you have a sluggish virtual machine (VM) and in trying to find the bottleneck, you raise the number of vCPUs? Did it work? If your VM experiences a slowdown, then the problem is the extra vCPU(s). It's counterintuitive to see this occur but it's a real phenomenon. To clarify, you might experience a performance hit by adding vCPUs to a VM. Crazy, yes, but there are some good reasons for it.
You also want to be careful of using multiple vCPUs and then moving back to a single vCPU. Some operating systems don't do well with that change. Windows Server 2003 being one of them.
So, if using multiple vCPUs might cause a performance slowdown, why would VMware and other vendors support them?
Good question.
The answer is simple. You need multiple vCPUs if your application running on the VM is multi-threaded and can use multiple processors. A good example is database servers. MS SQL Server, Oracle and others.
But, still why should performance take a hit by giving a VM more resources? The answer has to do with how CPU power is scheduled and parsed out to VMs. If you've given a VM four vCPUs, then that VM wants four free cores on which to run its processes. Finding four free cores at once might leave your VM a little hungry and hence the poor performance. Now, that's a great simplification of the situation but if you'd like an in-depth analysis of CPU performance, time slices, cores and more, pick up a good book on performance tuning.
If your application is single-threaded, like most legacy applications, do yourself a favor and use a single vCPU. And, find other ways to mitigate the performance problems. Here are some performance optimizations that don't involve vCPU number editing.
- Add RAM to your VM - This depends on your workload type. If it's RAM-intensive, increase the RAM. But, don't be wasteful with memory resources, allocate what's needed, monitor and adjust.
- Separate your virtual disks onto different LUNs - You can place virtual disks on different LUNs. You'll have to monitor your disk performance closely to decide where to relocate additional disks. An excellent method of moving VMDK files is to use the LostCreation's SV Motion VI Center plug-in.
- Adjust your pagefiles or swap space to better handle the workload - On Windows systems, set your pagefile to a static size for best performance (Twice RAM is a good size) and split up the pagefiles onto different disks (VMDKs), if possible. For Linux systems, place swap space into a separate VMDK, if possible.
- Don't use Screensavers. You don't need them on VMs.
- Add additional vCPUs only if your vCPU is sustaining high usage (90%-100%). Occasional bursts are to be expected, especially on Windows where you can peg the CPU by dragging a Window around the screen. In other words, don't fret over periodic high usage. It's a computer. It's supposed to process.
- Don't oversubscribe CPU - One vCPU translates to one physical processor core. You can throttle CPU usage, and should for most systems.
- Install VMware Tools - Install the Tools to gain more performance out of your VMs through enhanced network, video, mouse and other drivers.
There are other enhancements that you can try but these will get you started in the right direction.
So, the main point you should take away from this is to use single vCPUs for all VMs unless you have an extremely compelling reason to use more. And, there are very few compelling reasons to do so. My best advice is to experiment in a test environment first and measure performance closely. Of course, no test environment can fully emulate production and nuances that occur there with human users.
Write back and discuss your experiences with using multiple vCPUs and for which workloads you use them. I'm especially interested in your experiences with multiple VMs running in production with 4 or more vCPUs.
Kick off your day with ZDNet's daily email newsletter. It's the freshest tech news and opinion, served hot. Get it.
Talkback
RE: The Late Great Virtual CPU Debate
Managing performance in a virtual infrastructure is similar to managing performance in the "time sharing" world. Someone who did performance management on IBM mainframes, DEC VAX and Alpha servers running VMS, etc., would probably have some worthwhile experience here.
Performance problems can be caused by many different things depending on your workloads and the available resources to service them. Shared resources can provide much better return on investment, but they require a bit more planning and expertise to manage to business expectations.
The suggestions given above may or may not be valid depending on the circumstances - e.g., even oversubscribing CPU could be a valid business decision as long as the implications are acceptable - and most managers probably won't understand that.
RE: The Late Great Virtual CPU Debate
Not sure where you're getting your information. The guidelines given here are from experience and from VMware itself.
You should NEVER oversubscribe CPU. NEVER. If you do, you're going to choke your other VMs. Just because it's possible to do something doesn't mean you should.
And, performance doesn't have to be measured by some "performance guru." I have worked in Capacity and Performance for very large companies so I know what I'm talking about. There are some great performance packages out there and it doesn't take a guru to discern red from yellow from green, when looking at performance numbers. Following the guidelines won't cause you problems. It will solve them.
Message has been deleted.
My recomendation: Put as many vCPUs to your VMs as your server has..
RE: The Late Great Virtual CPU Debate
MY CPU checklist