I already briefly touched on Sparse Swap in my VSAN 6.2 launch article. When talking about space efficiency and VSAN 6.2 most people will immidiately bring up RAID-5/6 and/or deduplication and compression. Those of course are definitely the big ticket items for VSAN 6.2, there is no doubt. Sparse Swap however is one of those tiny little enhancements to VSAN that can make a big difference in terms of cost and space efficiency. And although I already briefly discussed it, I would like to go over it again and show you an example why it makes a difference and when it can make a big difference.
First off all a bit of history. Up to VSAN 6.1 all “swap files” were created with a 100% space reservation. This means that when you deploy a VM and the VM has 4GB of memory, and no memory reservation defined, that a swap file will be created and 4GB of disk space will be reserved for this swap file. Now keep in mind that in order to ensure availability that swap file is not a single 4GB object, but actually 2 x 4GB. You can imagine that with a single VM the cost of that swap file is negligible. But with 100VMs per host and 1600 in a cluster that single 4GB swap file per VM now results in:
1600 VMs * 4GB * 2 (FTT overhead) =12800GB capacity reservation
Note that even with with RAID5 or RAID6 the FTT overhead would still be 2*, this is because swap is a special object and VM Storage Policies do not apply to it. Note that no other VM / object can reserve or use the space which is reserved for those swap files. When Sparse Swap however is enabled (advanced host setting) no capacity will be reserved for those VM swap files. This means that instead of losing 12800GB capacity you now don’t lose anything.
When should you use this? Well first and foremost when you don’t overcommit on memory! If you are planning to overcommit on memory then please do not use this functionality as you will need the swap file when there are no memory pages available. I hope that this is clear and you only use it when you are not overcommitting on memory. Linked clone desktops is one of those use cases where swap files are a significant portion of the total required datastore capacity, leveraging Sparse Swap will allow you to reduce the cost, especially when running all-flash. So now that we know why, how do you enable it? Well that is really simple:
esxcfg-advcfg -s 1 /VSAN/SwapThickProvisionDisabled
I hope this article makes it clear that this small enhancement can go a long way! Oh and before I forget, this neat small but useful enhancement was the result of a feature request a customer filed about 3 – 4 months ago, just think about that for a second, that is agility / flexibility right there, and yes our customers come first.
Chip says
If this sparse swap is activated, what happens when a host is under memory pressure and VMs are therefore forced to swap? Is the VM able to do so? If so, what is the performance delta compared to traditional swapping on VSAN when the VM has to read pages in from the swap file?
Duncan Epping says
As long as you have capacity available on the VSAN datastore then the VM will just swap out, not a problem at all. But you need to have capacity available, without any capacity your VM will just die. When it comes to reading there is no Delta, that will work the same.
Cedric says
Can we activate this functionnality on a normal SAN environnement without VSAN ?
Personnaly I never have designed my clusters to use overcommitting on memory…
Duncan Epping says
No, this is not available for a normal SAN only for VSAN at the moment.
@verbrough says
Is it possible to add this advanced configuration option in a host profile?
Hiroshi Okano says
How about VM memory reservation? In order to reduce vm-swap memory consumption and if this setting use only no memory overcommitment environment, I think VM memory reservation is simpler solution.
Duncan Epping says
you think 1 setting per host is more complex than a setting per VM? Keep in mind that reservations are static and can lead to other types of challenges (like not being able to power-on a VM when memory cannot be guaranteed)
Hiroshi Okano says
Thanks. One more question. What kind of ESXi behavior is expected when the host encounters shortage of memory and needs swapping out some VMs memory?
Duncan Epping says
it will claim disk blocks and swap out, unless you are out of disk space. if you are out of disk space you have a problem, than again… you already had that