Why is it bad practice to keep VMware snapshots for extended periods of time?
I am just learning to use VMware Workstation. One of the main reasons I use it is because it allows me to take snapshots. This is great because I can jump back and forth in experimental changes.
However I heard from a YouTube video that keeping snapshots is a bad idea and that it is recommended to commit the changes of a snapshot or delete it to ensure performance stability.
VMware documentation says:
...for a better performance, use only 2 to 3 snapshots and do not use a single snapshot for more than 24-72 hours.
However it does not explain why it is imperative to keep snapshots for a short time only.
Can someone elaborate on this? I would like to keep different states of a virtual machine should I use snapshots or is there another way that, perhaps I have not head of?
When you make a snapshot, the original virtual disk is frozen and a snapshot file is created. From that moment on, all the changes that would otherwise be made to your virtual disk, are written to the snapshot file.
If you are happy with the new situation, you can commit the snapshot. All your changes will then be applied to your original virtual disk and the snapshot file can be deleted.
Otherwise, you can roll back your system to the state it was when you made the snapshot.
It is also possible to make another snapshot when you already have a snapshot. The original snapshot will then be frozen and all the changes go to the second snapshot file. You can continue this to create several roll-back points in history (as you already mentioned).
Over time, the snapshot file will grow, especially when you make a lot of changes to your system, like installing new software packages or deleting a large number of files. If you make several snapshot(s), they can even become bigger than the original disk.
I use snapshots when I have to upgrade one of the servers I am responsible for. If the upgrade succeeds and there are no issues, I commit the snapshot.
If however something goes wrong, I roll back the changes and make a copy of the server and do the upgrade on the copy in an attempt to find out what went wrong.
There is a performance penalty to snapshots. Your system must always see a consistent disk, so if it accesses the virtual disk, VMware Workstation will read from the original disk, apply the changes from the snapshot and present the result to your system.
VMware Workstation will use some smart caching to keep up performance, but that will become more difficult and slower as your snapshot grows and the number of snapshots grow.
If you want to keep a certain state, it is probably better to make a copy of the virtual disk (or the complete system) at that moment and keep that as a reference. The size of the copy will never grow and your system won't suffer averse effects of snapshots growing unlimited otherwise.
Although @NZD's answer is technically correct, I would like to add a different perspective. It all depends on what you are trying to accomplish. I use dozens different environments with multiple snapshots each. Some of those environments are for testing and have to be very stable, so they are kept for a long time, up to 6 months some times. You just have to be conscious of the problems that can occur when doing so, but it can be ok for you to do this.
When restoring to an old snapshot, we know that Windows and/or applications updates will be outdated. We know that it may cause trust relationships to domains to no longer be valid, we know that it's possible that the time was changed due to daylight savings time. But once you have take all this into account, you can have an environment that is very very stable, thus when testing changes to applications you are developing, the only changing factor is the applicator itself.
It really depends on what you are trying to achieve. If you are using the VM's for production machines, then I would suggest to follow NZD's answer, but then again if you are using it for production machines, I would suggest not using VMare Workstation, but something like ESX/ESXi instead for performance and stability issues.
All-in-all, my answer would be: It depends, this may in fact be ok. I think a bigger factor would be to make sure to keep the amount of snapshots to a minimum as this will slow down the VM a lot and take up lots of space.