If you have read some of my recent blogs, you know that I have been spending time testing XenDesktop 4 and Microsoft Windows 2008 R2 Hyper-V. I thought I would take a moment and highlight the top seven things I have learned during this testing. Some of these items I briefly mentioned in my previous blog Optimizing Windows 7 for FlexCast Delivery posted a few weeks ago.
1. Use Fixed-Size VHDs for the Drives
This tip perhaps has the greatest impact on performance. Quite honestly I had no idea about how much of a difference disk alignment influences performance until I started testing with a dynamic VHD. When using local disks for storage, this is generally not noticeable. However, when using block-level SAN storage, the difference could be significant. Using a fixed disk VHD prevents both fragmentation and disk alignment issues by pre-allocating all the required space when the file is created and not requiring that extra footer at the end of the file and effectively creating a SAN friendly file.
Numerous resources are available on internet to discuss this topic, but for the sake of simplicity, I will try to give a brief synopsis here. The smallest block of data written by the SAN is called a “stripe” and it normally crosses several sectors on the underlying LUN. The NTFS file system is formatted with blocks of data or clusters. A file is written to a cluster, which in turn causes a write to the SAN “stripe”. When the data block written from the virtual hard disk aligns with the SAN stripe, then only one disk is affected during the write. If that SAN stripe resides on a RAID1 or RAID10 array, then two writes will occur (a 2x write penalty) because the writes will be written on the primary disk and then again on the mirror disk. If SAN is on a RAID5 array, a three data disks and a fourth parity disk will be accessed causing four writes (4x write penalty) in a single parity RAID5 configuration.
When the data block is out of alignment with the SAN, that same single disk write is spread across multiple disks. For instance, if that write is on a RAID1 or RAID 10 array the single write operation becomes four write operations on the SAN. If it is on a RAID5 single parity array, the write operation becomes eight operations on the SAN. As you can see, a single write operation can quickly create a backlog of write operations on the SAN.
Unfortunately, the dynamic VHD file format needs to manage the size of the file, so at the end of each VHD file, is included a 512 byte footer. Every time a data block is added to the dynamic VHD, the footer is moved to the end of the file. Since the VHDs are normally written in 2MB blocks, the addition of this footer is virtually guarantees alignment issues with underlying SAN storage as it changes the offset of the file next to it. To further add to the overhead, as the file expands, the additional data blocks will be placed at the next available location on the NTFS partition, causing fragmentation of the file across multiple stripes.
2. Format VHDs with the Windows 7 Diskpart Utility
Windows XP setup and Diskpart utility create the boot partition with a 31.5 byte offset that causes misalignment with block-level disk subsystems. The Diskpart utility included with Windows 7 / Server 2008 has been corrected to create the boot partition at a more alignment-friendly offset. In essence, if the disk is over 4GB the utility will set the offset to 1024KB by default. If it is under 4GB, which is the case for most write-cache drives, it will set the offset to 64KB by default. I recommend manually creating the partition for VHDs and verifying it as well. To learn more about Windows Server 2008 disk alignment and how to configure it correctly with Diskpart, see the Microsoft KB #929491.
3. Include the .BIN File in the Disk Space Calculations
Microsoft Hyper-V always allows a machine to be placed in a suspended state, such that the contents of the machine’s RAM is saved to disk for later retrieval when the machine is resumed, similar to hibernation on a laptop. In order to prevent possibility that disk space is not available in the future for saving the RAM contents, when a virtual machine is started, Hyper-V creates a .BIN file that is equal in size to the RAM configured for the virtual machine. This .BIN file cannot be disabled or deleted and must be present for the virtual machine to start. The file is also stored in the same folder as the virtual machine’s configuration file. Therefore, when calculating the necessary disk space on a SAN to support virtual machines, be sure to add in space equal to the RAM of the virtual machines.
4. Configure Two Network Interfaces When Using Provisioning Services
The default network adapter for a Hyper-V virtual machine is the synthetic adapter, which is optimized for a virtualized environment. However, this adapter is purely virtual and cannot be associated with any BIOS-level hardware, virtualized or not. Since PXE booting requires a BIOS-level interface, the synthetic adapter cannot be used. Instead, Hyper-V includes a legacy network adapter that includes a BIOS-level integration and that supports PXE booting. The legacy network adapter must be added to the virtual machine and set as the default boot device.
To provide the best performance, the guest image should include both adapters so that the legacy adapter is used for PXE booting and the higher-performing synthetic adapter is used to pass the network traffic after the operating system boots. Both adapters can be connected to the same logical network since the synthetic NIC has precedence over the legacy network card in the route table.
5. XenDesktop Integration with VMM is Still Developing
The System Center Virtual Machine Manager (VMM) server provides numerous APIs for integrating with Hyper-V. XenDesktop supports the standard APIs for starting, suspending, resuming, and creating virtual machines. However, XenDesktop 4 does not utilize the Microsoft VMM GetRating API for any desktop-related operations. Without the support for the GetRating API, the XenDesktop infrastructure cannot intelligently placing virtual machines when creating or starting them.
When creating virtual machines with the XenDesktop Setup wizard, the wizard retrieves a list of hosts managed by the VMM server and then evenly distributes newly created machines across all the hosts that VMM has registered with it. In situations where the machines are being created on identical host hardware and for the first time, this behavior is desirable. However, if the host capacity is not identical or if they already have virtual machines the Setup wizard may overburden the host.
If you need to deploy additional virtual machines to unequally loaded hosts, one option is to use a VMM staging server, which has only servers of equal capacity registered with it. The XenDesktop Setup wizard can then be pointed to the VMM staging server. After the wizard completes, re-register the Hyper-V hosts with their permanent production VMM server, and adjust the desktop group properties as appropriate in the XenDesktop farm.
6. Virtual Machine Manager Design is Critical
Microsoft recommends protecting against failure by virtualizing the VMM Server and placing it on a highly-available cluster. However, this approach only protects against hardware failure, not against software failure. In situations where the VMM server is running but the service fails to respond communications between XenDesktop and VMM Server come to a halt. When the communication link is broken, the XenDesktop DDC stops sending connections to the desktops hosted on that VMM Server. As of now, protection against this type of failure is currently not available without the creation of custom detection and complex failover routines. For the time being, the best approach is to limit the number of desktops managed by a single VMM Server to around 1,000 so that it will not get overloaded.
7. Windows 7 Behaves Well When Virtualized
Windows 7 is a virtualization-aware operating system. Windows 7 includes several features which improve its performance in a virtualized environment. First, Windows 7 includes the Hyper-V Host Integration Services as part of the base operating system. Second, Windows 7 notifies the hypervisor when it is idle so the hypervisor does not schedule guest operations. Finally, Windows 7 provides improved storage and optimized page file management. When compared to Windows XP, an operating system that has no idea it is being virtualized and is supposed to reach end-of-life this year, Windows 7 is an attractive solution.
If you found this blog useful and would like to be notified of future blogs, please feel free to follow me on twitter @pwilson98.