posted

1 Comment

One of the Space Efficiency features of Virtual SAN 6.2 that is available for both All-Flash and Hybrid configurations, is the introduction of Sparse Virtual Swap files. Swap files on Virtual SAN by default, are created with the .vswp 100% reserved. In a thin provisioned/guaranteed capacity perspective, it could be said that they are effectively Lazy Zeroed Thick (LZT).

Virtual Swap files (.vswp) are created when a virtual machine doesn’t have a memory reservation equal to the amount of memory the virtual machine is configured to use. In short, a VM with 4GB of RAM configured, with no memory reservation will create a 4GB .vswp file. If a reservation is used, then the .vswp file will be the configured amount of memory minus the reserved amount of memory. The same VM with 4GB of RAM, along with a 2GB reservation, will create a 2GB .vswp file.

Virtual Swap files are given a Number of Failures to Tolerate setting of 1 (FTT=1) with a Failure Tolerance Method of Mirroring or FTM=RAID1 (Mirroring). As the storage policy of FTT=1/FTM=Mirroring stands, each object with that policy will require 2x the space (1 Mirror). 200 virtual machines with 4GB of RAM each (I’m thinking a small VDI deployment) with no reservations, would require 200 x (4GB + 4GB) or 1.6TB of space. That’s significant!

In cases where there is no memory congestion, and a virtual machine doesn’t use the swap file, it might be advantageous to have a swap file that is truly thin provisioned (the default in Virtual SAN).

In Virtual SAN 6.2, we introduced an advanced host setting called SwapThickProvisionDisabled, when enabled, removes the space reservation for .vswp files. The generic syntax for this command is:

Having to determine this configuration across more than a few hosts can be a bit of a pain without some scripting/automation.

On a 4 node cluster I spun up about 500 virtual machines with 4GB of RAM allocated each, and no memory reservations. Those swap files, as well as FTT mirrors consumed over 4TB of capacity.

thickswap

*Note the .vswp Mirrors don’t appear in Swap objects, but rather File System Overhead.

I powered off those virtual machines, changed the SwapThickProvisionDisabled setting, and consumed less than 4GB of Virtual SAN capacity.

thinswap

*Note the displayed File System Overhead includes mirrors of other virtual machines on the cluster.

That’s a huge difference. I could run the above esxcfg command on my hosts, but that’s a bit problematic. I’d much rather script this.

So I wrote a couple simple scripts for just that.

First I wrote one to query each host for each of the clusters attached to vCenter. It also checks for vSphere 6.0 Update 2, as the setting isn’t valid with previous releases of vSphere.

Pointing this script at my vCenter, I see the following:
Get-VSANThinSwap

My hosts are set to SwapThickProvisionDisabled = 0, for Thick Swap Files.

Another script changes that setting to SwapThickProvisionDisabled = 1.

And now each host will apply a space reservation of 0% to the .vswp files upon VM power on.
Set-VSANThinSwap

Keep in mind that VM’s will have to be powered off to have the .vswp file space reservation policy change from 100% reserved to 0% reserved.

If you want to change the setting back, the  (another) script will change the setting back to the default.

I hope this script helps better use this advanced Virtual SAN 6.2 feature to reclaim some space.

These scripts are available on the VMware Developer Center: https://developercenter.vmware.com/samples?id=971

Reposted from jasemccarty.com