Improve Virtual Machine Performance

Microsoft Virtual Server 2005 R2 SP1 is a server application that enables users to run a range of operating systems, including Microsoft Windows Server 2003 and Microsoft Windows 2000 Server, Windows XP Professional and Windows NT 4.0, plus a variety of legacy operating systems such as Windows 98. It will allow the operating systems to simultaneously run on a single physical server. Microsoft Virtual PC 2007 is an application that, like Virtual Server, allows users to run a wide range of virtual machines, but unlike Virtual Server it is mainly targeted for use on workstations and has less capabilities than Virtual Server.

Virtual Server 2005 R2 SP1 Virtual PC 2007

In any case, running virtual machines (guest machines) on your physical machine (the host machine) requires a lot of hardware resources, and unless properly configured, both the guest and host performance will be noticeably slow. Taking the time to perform the optimization tasks will greatly enhance your guest VMs performance, especially needed when using them in a production environment.

Hardware Considerations for Virtualization

First, we need to get our host hardware properly set up. I cannot tell you exactly how much memory or what type of disk you should be using, but I did compile a list of items that you should be aware of when planning to buy your host hardware:

  • CPU – as processor speeds increase, and as dual and even quad core become more and more attractive price-wise, you should consider getting a fast CPU for your computer. Note that newer processors will have the virtualization capabilities built in them, and although some of these features will only be properly utilized when the new Windows Virtualization (code named “Viridian”) will be released in the second half of 2008, you should still be aware of developments in that field. The rule of thumb is that the faster the CPU is, the better your computer will handle the extra load of running many VMs at the same time.
  • Memory – Another prominent consideration when running VMs is their memory usage. If you plan to run high-capacity guest machines, or if you plan to run many guest machines at the same time, you should plan for enough physical memory on your host machine. The host computer must have at least enough memory to cover the requirements of the operating system running on the host computer, in addition to all operating systems you plan to run simultaneously on virtual machines. The rule of the thumb is – the more the merrier. Make a note that the more guest machines you run at the same time, the more memory your host machine needs. Get as much memory as you need, and make sure it’s of a fast type.
  • Disk – Make sure that you have enough disk space on your host machine to host all the virtual disks of your guest machines. However, in this case, free space is not enough to make your VMs run faster. One of the major bottlenecks of using VMs is the disk I/O, especially on high-capacity VMs. You should place your guest machines on a separate hard disk, not the same one as your host system partition is on. For high-capacity VMs, you should even consider placing each VM on a separate disk. If you cannot attach another internal hard disk (i.e. in most laptop instances), you should consider using an external hard disk, and make sure you connect to it via USB 2. For even better performance consider placing your guest machines on a RAID0 array, or on a RAID1 array if you require fault tolerance. Also, using a SAN for VM hosting is ideal in cases of host clustering with Virtual Server, but naturally you wouldn’t want to spend so much money for simple lab or testing purposes. Another major consideration is the hard disk RPM and access speed. The faster the disk is, the faster the VM runs.
  • Network – Although not directly connected to the VM working performance, in production environments where Virtual Server will be used and the guest machines will actually be production servers, network interface cards (or NICs) are quite important. Most servers come with one or more 100/1000 Mbps NICs, but you should try to connect them to a properly configured switch with the correct speed. You can expect a small degradation in network performance when compared to a true physical computer, but in most cases that won’t be as crucial as the disk subsystem bottleneck. In any case, using Gigabit Ethernet network interface cards can improve overall performance, because even though the guest machine emulates a 100Mbps connection, when you have multiple VMs running, the performance increase will be noticeable.

Guest Software

Using a proper guest operating system, one that can handle the load and additional hardware, is crucial to the virtual machine performance. If you need to run Virtual Server in a corporate environment you should use it on Windows server 2003 SP1 or above, and as Microsoft approaches the release of Windows Server 2008, we will see more and more information on using it as your host machine.

If you plan to use Virtual Server or Virtual PC on your workstation/laptop you should consider using Windows Vista Business edition and above, mostly because of better hardware support, better memory management, and hardware virtualization support.

Other software considerations

Besides choosing the proper host operating system there are many considerations when configuring your operating system and installed software. Here is a list of some of these considerations:

  • • Anti-Virus Software – Whatever AV software you’re using on your host machine, make sure you exclude all the VM files from the AV real time scans. The file types you should exclude are:  
    • .vhd
    • .vud
    • .vsv
    • .vfd
    • .vmc  
  • NTFS compression – NTFS compression is a good idea for unused files INSIDE the guest virtual hard disk, AND on the virtual hard disk files themselves. The reason for the first is to make the virtual hard disks use less space on your host machine (true in case of using dynamically expanding disks). The files will turn out to be around 30% smaller on the hard disk. The reason for the second is that access times for the disk will be faster, and today’s fast CPUs are quite capable of handling the overhead of using NTFS compression. It seems writing a big chunk to the hard disk is a lot slower than first compressing the chunk and then writing it to the hard disk.
  • Memory optimizations – The /3GB should not be used on the host machine. Using this setting will in fact increase the User memory space at the expense of the Kernel memory space. Virtual machines use more kernel memory than user memory – so enabling this switch on the host will decrease the amount of virtual machines that you can launch.
  • Memory allocation for the guest machines – Make sure the VMs have sufficient RAM allocated to them. This avoids the need to swap too much memory to the VM hard disk and reduces I/Os to the hard disk.
  • Use Differencing disks – Differencing disks offer the ability to create a base .vhd (including just the operating system for example), and then write all differences to a new virtual disk. The differencing disk might contain alternate applications or configurations. By doing this you can save space on your host machine. You can read more about it on my “Creating Differencing Disks with Microsoft Virtual PC” article.
  • VM Additions – Always make sure the latest Virtual Machine additions are installed on the guest machines. The current version of the VM Additions in Virtual PC 2007 is 13.803 and the current VM Additions in Virtual Server 2005 SP1 are 13.813.
  • Network connections in the VM – Always have the VMs connected to a network – even if it is the “Internal Only” network.
  • Remote control your VMs with RDP – Use RDP to connect to your guest machines just like you’d remote control a physical machine. Using RDP has some benefits: You can copy and paste data into the virtual machine, you can directly share data between your host and virtual machine directly, and you can share access to your host’s printer.
  • Defragment your VHD files – Smaller and less fragmented VHD files run faster. In order to do that, run defrag on your guest machines, and then run the virtual machine precompactor tool.
  • Create the VHD as fixed size disk – Unless you’re short on disk space, you’d be better off by using fixed size virtual disks because the disk space is allocated as one big chunk.
  • System optimization – Virtual Server 2005 runs smoother when selecting “Background Services” on the System advanced tab > Performance > Settings button > Advanced tab > Processor Scheduling.

Summary

Running virtual machines as guests on your physical host machine is quite simple, but without optimizing your machine the performance of the guest machines will not be as good as it should. Taking the time to perform the optimization tasks will greatly enhance your guest VMs performance, especially needed when using them in a production environment.

Related Articles

Recent Virtual Server & PC Forum threads

Got a question? Post it on our Virtual Server & Virtual PC Forum!