Getty Images

Follow these steps to optimize Hyper-V performance

Follow these best practices for Microsoft's virtualization platform to prevent unnecessary slowdowns with your VMs.

Hyper-V is a great product when you need a quick and easy-to-use virtualization stack, but the platform needs regular maintenance to prevent problems and keep performance running at top speed.

In organizations that rely on highly performant VMs on Hyper-V, it's important to keep an eye on these important workloads and make adjustments when necessary to keep them at optimal speed. If best practices are not followed, then inefficiencies can creep in to slow down VMs and even introduce problems that require troubleshooting. This article explains how to stay ahead of any problems by optimizing Hyper-V performance.

What can happen when VMs are not maintained?

System neglect can introduce issues, such as out-of-date drivers and VMs configured with suboptimal defaults. One typical example is choosing the proper network drivers; using the paravirtual driver improves performance compared to the standard out-of-the-box deployments. The driver should install automatically, but it's one area worth checking to be sure.

By themselves, these may be small issues. Combined, they can rob the Hyper-V environment of performance and reliability. Over time, those VM disks fragment, and speed suffers because the data resides on noncontiguous sectors. This is not a problem in solid-state drive-based implementations, but this can be an issue for environments with storage running on hard disk drives.

Here is a look at some simple but effective strategies for keeping everything running smoothly.

How to deal with Hyper-V patching

Like any software product, Hyper-V needs patching, as do the VMs located on the host. One tip is to separate the patching windows for Hyper-V hosts and VMs. The last thing an administrator wants is a server reboot that takes down all the running VMs as the host shuts down. A bad patch on a Hyper-V host can affect the production VMs, so it's recommended to apply the patch in a test environment to avoid downtime. Planning reduces the chance of these incidents and avoids unnecessary troubleshooting.

What are the benefits of VM optimization?

A well-maintained environment brings several benefits. You can add more VMs on the same hardware and have them all run smoothly.

An example of optimization is using Hyper-V guest services, also called Hyper-V integration services. This provides better UX and installs drivers to optimize Hyper-V performance over the baseline drivers.

Check for unnecessary hardware attached to the VM. Depending on the setup, you may find a VM with sound cards and disk adapters attached, which aren't needed. They consume small amounts of RAM and CPU that can add up.

Remove attached CDs that can hinder migration operations. This practice also prevents potential problems during reboots if a boot order change puts the CD-ROM first.

Depending on how the administrator wants the environment to work, it may be prudent to disable the auto restart of VMs. Dozens of VMs rebooting at once can strain the storage system and cause a large I/O issue. Manually powering on VMs can help the administrator avoid this problem, but when the host reboots, the administrator needs to start the VMs. One way to alleviate the reboot issue is to use the automatic delay to stagger startups.

How to monitor VMs and identify areas of improvement

Performance is subjective, but typical symptoms of underperforming VMs include poor response time and high CPU utilization, leading to tasks and applications stopping or not responding. Other typical symptoms include tasks that take longer than usual to complete.

One major thing to look at is resource contention. The Hyper-V host only has so much RAM and CPU to go around. Does the issue affect one VM or several?

If several VMs are not performing well, then the physical system might be maxed out. Use the performance monitor on the host to get statistics. Inside the VM, use the performance monitor to add the counter called CPU wait time per dispatch. This counter measures in nanoseconds how long the virtual CPU must wait to use the physical CPU. Generally, a measurement of more than 100,000 indicates contention and speed issues. The only fix for this issue is more hardware. The administrator can reduce the number of VMs running concurrently as a temporary solution.

If the virtual CPU (vCPU) constantly runs at full utilization, then that indicates an additional CPU is needed. The best advice is to add additional vCPUs in smaller increments because it's possible to have poor performance caused by too many CPUs.

Making sure enough memory is available is critical. One useful Hyper-V feature is dynamic memory allocation. By default, it is turned on. It enables the Hyper-V host to dynamically allocate RAM to VMs as needed, subject to sizing minimums and maximums. It's imperative to run tests with this feature because it might not work well with certain applications.

Perform regular Hyper-V maintenance tasks

Regular maintenance on the Hyper-V virtualization platform includes patching the hosts with software updates from Microsoft. In addition to security patches, Microsoft releases bug fixes and other improvements during the mainstream support period. These updates apply to Hyper-V integration services, which are the equivalent of VMware Tools on the VMware platform. It's important to keep the system up to date for top Hyper-V performance.

Be sure to remove unattached VHDX files. When administrators delete a VM but neglect to select the option to delete disks, they can leave behind disconnected files. If a single standalone host only has a few VMs, this file storage cleanup work is easily done manually, but administrators should save the files in a separate folder before deleting them. That way, if a mistake was made, then those disks can be restored.

In the same vein, Hyper-V snapshots are useful as point-in-time copies to roll back changes quickly, but left unattended, the snapshots can consume massive amounts of disk space. VM performance can also suffer due to an excessive number of snapshots by adding to the complexity of the system's read/write operations. This drags down performance not only for that one VM, but any VM that uses the same set of underlying physical disks.

General tips to maintain Hyper-V reliability

The key to a well-running Hyper-V environment is the effective management of resources. Running out of resources is problematic, but none more so than disk space. Dynamically sized disks, also known as thin-provisioned disks, should be carefully monitored. It makes sense to separate the Hyper-V machine disk files from the OS disks. It's helpful to use a monitoring tool to set a threshold to send an alert if disk capacity reaches a certain threshold, such as 90%.

Best practice states that the Hyper-V disk files should reside on a separate partition to reduce the chances of filling the Hyper-V boot disk.

Stuart Burns is a virtualization expert at a Fortune 500 company. He specializes in VMware and system integration with additional expertise in disaster recovery and systems management. Burns received vExpert status in 2015.

Dig Deeper on IT operations and infrastructure management

Cloud Computing
Enterprise Desktop
  • Understanding how GPOs and Intune interact

    Group Policy and Microsoft Intune are both mature device management technologies with enterprise use cases. IT should know how to...

  • Comparing MSI vs. MSIX

    While MSI was the preferred method for distributing enterprise applications for decades, the MSIX format promises to improve upon...

  • How to install MSIX and msixbundle

    IT admins should know that one of the simplest ways to deploy Windows applications across a fleet of managed desktops is with an ...

Virtual Desktop
Close