As a VMware Admin, We would have received a lot of support request. Most of them are related to the resource settings of Virtual Machine either increasing or decreasing the VM resources and another common request will be configuring VM reservation especially VM memory reservation settings. When it comes to VM memory reservation settings, We recommend the support team to Power off the VM to configure the VM memory reservation settings for the changes to take effect. We need to ask the question what will happen if I configure VM memory reservation setting is configured on powered on virtual machine. This article talks about the impact of changing VM memory reservation settings on the fly.
I have a virtual machine called “DB-Tier” configured with 4 GB of memory without any memory reservation configured.
Every powered on Virtual Machine on the ESXi host will have a .vswp file (swap file ) associated with it. This .vswp file will be stored in the Virtual Machine directory by default. This .vswp file will be automatically deleted when the virtual machine is powered off. By default, the .vSwp file size is same as the configured memory size of the Virtual machine. This .vswp file will be used if the host is actively over-committed and highly utilized. In that instance, ESXi host will start swapping the VM memory from the host’s physical memory into the .vswp file just like as operating system does when running out of memory. ESXi host has many memory management techniques like TPS (Transparent page sharing), Memory Ballooning and Memory Compression. Swapping will be last restore memory management technique handled by ESXi host.
VM configured with 4 Gb of memory has 4 Gb .vswp file created in the virtual machine directory.
Configuring Memory reservation of Powered-on Virtual Machine :
Memory reservation is a guarantee of memory resources for a virtual machine from the available physical resources. If you reserve 2 Gb of memory on a guest with 4 Gb of RAM, you are guaranteeing that the guest will always have access to 2 Gb of physical memory on the host.
Setting a 2 Gb reservation on a guest configured with 4 Gb of RAM means you will never swap more than 2 GB out to the .vswp file. Powering on this VM will result in a .vswp file of 2 GB file.
I have configured the Memory reservation of this powered on the Virtual machine to 2 GB. As per the above discussion, if 2 Gb out of 4 Gb of memory is reserved, the .vswp file should also change it to 2 Gb. Since I have configured reservation on powered-on VM, the .vswp file was not reduced from 4 GB to 2 GB.
once I powered off the VM and Powered on again, .vswp file automatically reduced from 4GB to 2 GB.
Removing the VM Memory Reservation of Powered-on Virtual Machine:
For the VM configured with 2 Gb of reservation out of 4 GB, the .vswp file size will 2 Gb. When I changed the VM reservation from 2 Gb to 0 MB, my .vswp file automatically increased to 4 GB of size.
Final Observation:
- Swap(.vswp) file will be created during VM power on and deleted at power off
- Swap (.vswp) file size = Allocated memory minus Reserved Memory (VM Configured Memory – VM reserved memory)
- Swap file size will increase on the fly when you reduce the Memory Reservation.
- Swap file size will not decrease as reservation is increased (new size will take effect at next VM power cycle)
I hope this post will help you to understand the impact of changing the VM memory reservation settings on Powered on Virtual machine. Thanks for Reading!!!. Be Social and share it on social media, if you feel worth sharing it.