Shorter is better. Simpler is faster. When you’re looking to get from Point A to Point B in the real world, if all other factors are equal the shortest route will be the fastest. This also applies in the computing world, but over time hardware and software engineers have come up with many ways to cheat on this maxim. Virtualization is one step removed from the shortest path – an OS directly on the native physical box – so its performance has always been a topic of interest. When you’re thinking about a Hyper-V implementation, what kind of performance optimization should you be doing?
There are four major subsystems to focus on in any discussion of computer performance tuning: processor, networking, memory, and disk I/O. I have first-hand experience with VM disk I/O limitations compared with native physical systems. When I was working at Intel, our team participated in Microsoft’s Windows Server 2008 Technology Adoption Program. As part of the program, we tested an upgrade of Intel’s entire corporate Active Directory (AD) from Windows Server 2003 to Windows Server 2008 in a special lab at Microsoft’s Enterprise Engineering Center. To do this we used Virtual Server and promoted a virtual AD domain controller into each production domain, copied them to a USB drive, and hand-carried them to the lab. One of our unexpected lab learnings (after spending hours and hours waiting for domain controller promotions to complete as we expanded our little portable Intel) was that Virtual Server had really slow I/O performance.
Fortunately, Hyper-V has a completely revamped I/O model that’s vastly improved over Microsoft’s previous server virtualization product, and it’s gotten better with R2. Before this release, it was a rule of thumb that for maximum performance you should always have virtual hard disks (VHDs) that were fixed in size rather than dynamic disks that would grow as the VM’s space requirements dictated. Tony Voellm, the Hyper-V Performance team lead, has posted a list of performance improvements between Hyper-V’s initial release and its R2 update. One of the more notable improvements is that dynamic disk performance in R2 is now nearly identical to fixed disk performance. The simplified management and space savings you’ll get with dynamic disks will outweigh the tiny difference in performance with a fixed disk configuration. Be sure to have disk defragmentation enabled in both the host and guest, however.
Hyper-V allows you to control how a host’s VMs control the host’s processors (or processor cores, when you have a multicore machine) in three ways. You can have a VM set a reserve on processing resources so it’s guaranteed a certain percent of processing time. You can set a maximum percentage of processing percentage to be sure a VM doesn’t use too much processor resource. Finally, you can set a relative weight on a VM so it’s favored to get more processor resources in times of heavy usage. You should use these controls very sparingly. No matter how you tweak these controls, you only have so many physical processors or cores to go around, and favoring one will always hurt the other VMs on the host. A circumstance where you might want to use processor weighting is where you have an important, transactional line of business VM on a host with less important VMs. However, it’s also reasonable to assume you have this system in a cluster with real time migration, so if it suddenly has to move to another node in the cluster, this favored machine will be throwing its weight (if you’ll pardon the pun) around on the new node and affecting its VMs.
Just like with physical systems, the single best performance boost you can give your VMs is to allocate them plenty of memory. At the same time, physical memory on a host is also its most limited resource. How much memory should you give the host’s parent partition and its other VMs? The simplest advice is to size them as you would size a physical machine, plus a small amount extra for VM overhead (32 MB for the first 1 GB of virtual RAM plus another 8 MB for each additional GB of virtual RAM). For both security and performance reasons, you shouldn’t install other roles or applications on the parent partition. It should have between 512 MB and 1 GB of memory to ensure it has plenty of memory for I/O virtualization, management, and snapshot support.
In the network subsystem, the best way to ensure good performance of a VM within a host is to have Hyper-V Integration Services installed and using the latest synthetic network device drivers. These device drivers take advantage of the VMBus I/O architecture, which is much faster than the legacy emulated device drivers. When you’re looking at new physical network devices for your virtual infrastructure, look for devices that support Virtual Machine Queues (VMQ) and or Chimney Offload. These network performance features are newly supported in Hyper-V R2.
As with the company’s operating systems, Microsoft is trying to make Hyper-V relatively self-tuning. And like its Windows OSes, the best way you can improve Hyper-V’s performance is to give it more resources. In performance tuning, there will always be a bottleneck in one of these computer subsystems because one will always be slightly more constrained than the rest. Once that constraint is eased, the load will shift to what is now the most constrained subsystem. Performance tuning is all about minimizing these bottlenecks in turn until they’re so small your system doesn’t appear to have any constraints at all.