There are several ways to improve the performance of a Hyper-V host and the virtual machines running on it. One example is Hyper-V Best Practice Analyzer, which analyzes a Hyper-V configuration and produces a detailed report that identifies issues that might result in poor performance. Although Hyper-V Best Practice Analyzer can be used to check configuration issues for compliance purposes, it does not really help in addressing performance issues caused by background activities happening on the Hyper-V OS and virtual machines. The background activity on both the Hyper-V server and virtual machines causes a lot of CPU cycles, and that, in turn, decreases the overall performance of the Hyper-V server.
Before diving into the tips you can follow to disable background activities, you need to know why it is necessary to do so. As part of best practices, it is recommended that you enable the Dynamic Memory feature for virtual machines (VMs). Enabling Dynamic Memory will allow the Hyper-V host to allocate memory to VMs when needed. This is fine as long as Hyper-V allocates memory if an application running inside a VM demands the memory. However, it is undesirable when Hyper-V allocates memory to a VM just because the memory is needed by the background activities happening in the VMs. Here are some commonsense tips you can follow to disable background activities inside the VMs running on the Hyper-V host.
Disable automatic maintenance: Windows Server 2012, Windows 8 and later OSes support the Automatic Maintenance feature. As part of Automatic Maintenance, a Windows OS executes a series of tasks in the background, such as software updates, security scanning and system diagnostics. Although running a maintenance activity has minimal impact on performance, it is advisable to disable maintenance activity on Hyper-V hosts and Windows VMs. This is because a timer running in the system always uses the processor time to know when this activity needs to be executed.
Minimize or close unnecessary application windows: A maximized application window will consume more memory than a minimized application window. It is recommended that you minimize the application windows on the Hyper-V host. You must also consider closing the VM connection windows if they aren't in use.
Disabling scheduled tasks and unnecessary services: As part of best practices, many organizations follow a basic Windows OS hardening template. You might want to review the OS hardening template to include disabling unnecessary scheduled tasks and Windows services on Hyper-V OSes and VMs. Since scheduled tasks can be configured to run periodically, they might be the top pollutants decreasing the overall performance of the Hyper-V host and VMs. Generally, a Hyper-V host is used for virtualization activities performed by the Hyper-V services. So, it is recommended that you run the Hyper-V role on the OS with a minimal set of Windows services.
Exclude Hyper-V processes and directories in antivirus: Antivirus software adds an extra layer of communication when applications access files on the disk. This extra layer of communication causes disk I/O, which, in turn, causes processor time to be used. To ensure that the antivirus products do not interfere with the operational activities of Hyper-V, it is recommended that you exclude Hyper-V processes and all folders containing VHD, VHDX and XML files.
Use Server Core for guests: If you plan to host only server roles and features such as DNS, DHCP, Active Directory, Failover Cluster and applications that can be installed in the Server Core, it is recommended that you choose Server Core OS for Windows VMs. Server Core does not implement the GUI or Windows Explorer Shell. Since the Windows Explorer shell (Explorer.exe) causes most of the background activities in Windows OS, using Server Core helps reduce overall CPU utilization/cycles.
Disable screensaver: A screensaver also uses a small amount of processor time. Disabling the screensaver is recommended on both the Hyper-V OS and on VMs. A screensaver keeps the system busy, which causes CPU cycles.
Disable automatic defrag in Windows VMs: Disk defragmentation is set to run automatically in Windows 7 and later OSes. Although it is recommended that you run the defrag activity once a week, it is a good practice to change the scheduled time so it does not hinder Hyper-V host activities.
Disable periodic timers in applications in VMs: Another way to prevent poor performance is to look at the internal timers inside applications running in VMs. These internal timers are configured to run application activities in the background periodically. You might want to review and reduce the number of these periodic activities by disabling their timers.
Remove legacy hardware devices from VMs: Removing legacy hardware devices from VMs, such as network adapters and IDE controllers, can also prevent poor performance. A legacy device always presents an extra layer of communication and requires the host OS to intervene before it can communicate with hardware devices, resulting in utilizing the processor time. On the other hand, VMBus devices, such as synthetic network adapters and virtual SCSI controllers can directly communicate with the hardware, thereby eliminating the need to talk to the host OS.
If you're still experience poor performance, here are some other tweaks you can try:
- Install the latest version of the Integration Components in the VMs. Microsoft keeps updating the Integration Components to address common performance issues.
- Detach devices such as CD-ROMs, the COM port, and hard-disk controllers from the property page of VMs. A device in use always uses some processor time.
- Use generation 2 VMs whenever possible. They remove legacy hardware, such as IDE controllers and legacy network adapters.
- Keep the Windows VM on the sign-on screen when it's not being used.
- It is also recommended that you disable Windows SuperFetch, Windows search and visual effects in Windows VMs to reduce the CPU cycles.