Windows Virtual memory, also known as Windows pagefiles, has been part of Microsoft Windows since Windows 3.0. Microsoft introduced virtual memory in response to the failures of Windows 1.0 and Windows 2.0, attempting to slash resource requirements for the operating system. Since then, not much has been discussed about paging until VDI became mainstream.
Not many technologies can be so simple and at the same time so complex to manage and understand. Because of that I have put in order a recollection of articles and recommended practices to help us better understand what steps can and should be taken to optimize disk swapping performance.
A virtual machine will almost often have two types of pagefile.
1. Windows Pagefile (pagefile.sys)
2. .vswp (memory overcommitment on a ESX server)
Before discussing both type of swap it’s important to understand that ESX server uses an advanced technique to optimize memory utilization in the system. These techniques include Transparent Page Sharing (TPS), ballooning and swapping. ESX scans the memory used by virtual machines to determine identical memory pages and transparently collapse them into single copies that are accessed (read-only) by all the VMs.
Ballooning is the technique used by ESX to force a guest system to swap inactive memory pages to its internal pagefile (1) and utilize the freed physical RAM to serve other active VMs. As a fallback, when the system memory is overly utilized, ESX will swap to disk memory from virtual machines (2). Each virtual machine has its own .vswap file maintained by ESX.
(2) “VM disk swap (.vswp) is created if the reservation is less than 100% of a virtual machine’s RAM. The size of the swap file is equal to the unreserved portion of guest RAM. For example, if 50% of guest RAM is reserved and guest RAM is 2GB, the .vswp is 1GB.” vSphere4 – Desktop virtualization notes If the host is already under heavy memory contention the last thing you want is to create another point of contention.
“It’s a good idea to either create partial memory reservation for your VM’s or specify an alternate location for this file so it does not use up valuable VMFS SAN space. By creating a partial memory reservation you can decrease the size of this file and still allow for memory overcommitment, you also allow for ESX to use its advanced memory techniques such as page sharing. Alternately you can specify an alternate location for the .vswp file so it is not stored in the same directory as your .vmdk files.” esiebert7625
(1) “The Windows OS starts paging when 75 percent of its memory is allocated. It will always try to keep at least 25 percent free. But paging in virtual environments is a performance-killer. So instead of giving it the recommended (in physical systems) amount of 1.5 to 2 times the amount of memory in swap space, we limit the pagefile size to a fixed amount of 200 to perhaps 500 MB. If that is not enough, just add more RAM to the client, rather than extending the pagefile.” Petervandenbosch
“As this data is transient in nature we can save a fair amount of storage and/or bandwidth capacity by removing this data out of the datastore, which contains the production data. In order to accomplish this design the VM’s swap or pagefile must be relocated to a second virtual disk, stored in a separate datastore.” NetApp and VMware Virtual Infrastructure 3 Storage Best Practices
“Blocks of data are written in sequence to all disks in a RAID0 set but only to one at the time. So if one disk in the set fails, all data from the set of disks is lost. But because there is no overhead in a RAID0 set, it is the fastest way of reading and writing data. In practice this can only be used for volatile data like temporary files and temporary caches, and also perhaps for pagefiles. If used, the amount of IOPS a RAID0 set can provide with 15,000 RPM disks is 150-160 for reads and 140-150 for writes.” Deep Impact
When dealing with VMware View and virtual machines using Linked Cloning things start to get even more interesting. Because, by default, the pagefile is located on C:\, every time Windows swap memory to disk the delta .vmdk is incremented consuming additional storage space. It is a good practice, even when using Linked Clones, to create a new .vmdk specific for Windows virtual memory. I have also tested using pagefile on UDD (User data Disk) and that is also works well even after the machine is provisioned. If you still have doubts about how linked cloning technology works look here, here and here.
The flow below demonstrates the steps you can take to provide your VDI environment with the best swap management.
The same steps are applicable to any virtual machine with or without Linked Clone.