{"id":332,"date":"2010-01-22T22:16:38","date_gmt":"2010-01-22T21:16:38","guid":{"rendered":"http:\/\/vmdamentals.com\/?p=332"},"modified":"2011-12-29T11:41:23","modified_gmt":"2011-12-29T10:41:23","slug":"performance-impact-when-using-vmware-snapshots","status":"publish","type":"post","link":"https:\/\/www.vmdamentals.com\/?p=332","title":{"rendered":"Performance impact when using VMware snapshots"},"content":{"rendered":"<blockquote><p>It is certainly not unheared of &#8211; &#8220;<em>When I delete a snapshot from a VM, the thing totally freezes!<\/em>&#8220;. The strange thing is, some customers have these issues, others don&#8217;t (or are not aware of it). So what really DOES happen when you clean out a snapshot? Time to investigate!<\/p><\/blockquote>\n<p><BR><BR><strong>Test Setup<\/strong><\/p>\n<p>So how do we test performance impact on storage while ruling out external factors? The setup I choose was using a VM with the following specs:<\/p>\n<p><!--more--><\/p>\n<ul>\n<li>Windows 2003-R2-SP2 VM (32 bit);<\/li>\n<li>Single vCPU;<\/li>\n<li>2048 MB memory;<\/li>\n<li>5 Gbyte boot drive as an independent disk on a SAN LUN;<\/li>\n<li>VM configuration and 4 GByte performance-measurement-disk on local storage (10K disks RAID1);<\/li>\n<li>IOmeter (version 2006.07.27) installed;<\/li>\n<li>Configure perfmon to measure both reads and writes per second from PhysicalDisk with a 20 second interval;<\/li>\n<li>Build these VMs on both an \u00a0ESX3.5 and vSphere server to see any differences.<\/li>\n<\/ul>\n<p><BR><br \/>\nNote that the VM configs were also placed on local storage. This setup creates the situation that the measured disk lies on local storage, and the snapshot is also created there (without fiddling with custom lines in the *.vmx file). Because the bootdisk is an independent disk, it will not be snapshotted at all (thus not impacted during the test).<\/p>\n<p>IOmeter was setup for a total of two tests. In the first test the delay between IOPS was set at 25 [ms], during the second test the delay was set to 0 [ms]. For both tests these workers were used:<br \/>\n<BR><br \/>\n<center><\/p>\n<table>\n<tbody>\n<tr>\n<th>Worker name<\/th>\n<th>Block size<\/th>\n<th>Read \/ Write<\/th>\n<th>Seq \/ Random<\/th>\n<th>Nr of sectors<\/th>\n<th>Resulting File Size<\/th>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\">Writer<\/td>\n<td style=\"text-align: center;\">4KBytes<\/td>\n<td style=\"text-align: center;\">100% write<\/td>\n<td style=\"text-align: center;\">70% random<\/td>\n<td style=\"text-align: center;\">2.000.000<\/td>\n<td style=\"text-align: center;\">1 GByte<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\">Reader<\/td>\n<td style=\"text-align: center;\">4KBytes<\/td>\n<td style=\"text-align: center;\">100% read<\/td>\n<td style=\"text-align: center;\">70% random<\/td>\n<td style=\"text-align: center;\">2.000.000<\/td>\n<td style=\"text-align: center;\">1 GByte<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><em>Table 1: IOmeter setup<\/em><br \/>\n<\/center><br \/>\nBoth tests were performed using these steps:<\/p>\n<ol>\n<li>Boot the VM;<\/li>\n<li>Start perfmon logging (measure both read- and write operations per second (ROPS and WOPS);<\/li>\n<li>Delete the IOmeter test file and start IOmeter workload;<\/li>\n<li>Measure the IOPS performed without a snapshot in place;<\/li>\n<li>Stop IOmeter, delete its test file;<\/li>\n<li>Create a snapshot within VMware (do not snap memory);<\/li>\n<li>Restart IOmeter after the snapshot is created;<\/li>\n<li>Measure the IOPS performed with a snapshot in place;<\/li>\n<li>From VMware, select &#8220;delete snapshot&#8221;;<\/li>\n<li>Measure the IOPS performed until the snapshot is deleted;<\/li>\n<li>If the snapshot cannot be deleted, stop IOmeter then wait for\u00a0successful\u00a0snapshot deletion;<\/li>\n<li>Stop perfmon;<\/li>\n<li>Save the following data: VMware realtime stats for ROPS and WOPS on both a host and VM level, perfmon stats;<\/li>\n<li>Put all data from step 13 into one big Excel file.<\/li>\n<\/ol>\n<p><BR><BR><strong>How VMware snapshotting works<\/strong><\/p>\n<p>VMware has chosen to do its snapshotting exactly opposite to the way most SAN vendors perform snapshots. In VMware, all blocks to be written to the VMDK are actually written to a (growing) snapshot file. This snapshot file grows in increments of 16MB.<\/p>\n<p>By using this type of snapshotting, the original virtual diskfile (VMDK) is not modified anymore, which makes it very easy to for example use some backup appliance to copy it out. Also, reverting the snapshot (going back to the original state) is easy; basically just remove the growing snapshot file because the VMDK file was left unmodified.<\/p>\n<p>But who ever reverts snapshots on a regular basis? Most snapshots are comitted to the original VMDK afterwards (backup scenarios!). This poses a problem, because when you commit the snapshot (in VMware this is confusingly called deleting of a snapshot) you have got to read the entire snapshot file, and write all those blocks back into the original VMDK. This is what is thought to be the issue with freezing VMs while snapshots are committed.<\/p>\n<p>Another problem in committing\/deleting a snapshot within VMware is where to put the data that is written during the committing of the snapshot. One could of course just freeze the VM, commit all data from the snapshot to the original VMDK, then unfreeze the VM. This would be a far from acceptable solution though (a large snapshot takes a lot of time to commit). That is why VMware has come up with a solution: create a second snapshot&#8230;<\/p>\n<p><BR><BR><strong>How VMware snapshot deleting works<\/strong><\/p>\n<p>Let&#8217;s assume we have a VM with a snapshot. Now we delete the snapshot. So what happens?<\/p>\n<p>First, VMware creates a second snapshot, which is a child of the first snapshot. All writes that the VM performs now, go into the second snapshot. The first snapshot is then committed to the base disk.<\/p>\n<p>When the first snapshot is deleted succesfully, you end up with kind of the starting problem: a VM with a snapshot attached. Hopefully though, this second snapshot will be smaller than the previous one. VMware simply repeats this process, right until the one remaining snapshot is small enough (16MB at max from what I&#8217;ve seen). Then VMware freezes IO to the VM, commits the final snapshot, and unfreezes the VM. Because the snapshot was so small, the time the IO is frozen remains acceptable.<\/p>\n<p>However nice this may seem, you might understand that snapshot deletion could actually fail if the VM writes too much data. In this case, the second snapshot grows faster than VMware itself can commit the first one to the base disk. This can actually mean your snapshot effectively will grow every iteration instead of getting smaller!<\/p>\n<p><BR><BR><strong>Test results: \u00a0Overall read\/write performance during snapshotting<\/strong><\/p>\n<p>The first test turned out to perform just about 32 ROPS and 32 WOPS\u00a0simultaneously, not saturating the RAID1 mirrorset of 10K SAS disks at all. Performance for both ESX3.5 and vSphere were almost equal, so I&#8217;ll just show the output for ESX3.5 here. The graph:<br \/>\n<center><br \/>\n<img decoding=\"async\" class=\"alignbottom\" title=\"Snapshot impact with average IOPS\" src=\"http:\/\/vmdamentals.com\/wp-content\/uploads\/2011\/12\/Snapshot-impact-average-iops.png\" alt=\"Snapshot impact with average IOPS\" \/><br \/><em>Graph 1: Average IOPS from a VM in conjunction with a snapshot<\/em><\/center><br \/>\n<BR><br \/>\nSo what are we looking at here? Lets look at the different parts of the graph:<br \/>\n<center><\/p>\n<table>\n<tbody>\n<tr>\n<th>Sample<\/th>\n<th>Event \/ Action<\/th>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\">01<\/td>\n<td>IOmeter starts to create its testing file. We see a lot of WOPS now<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\">10<\/td>\n<td>Test file is created, IOmeter starts its 25[ms] interval performing ROPS and WOPS<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\">13<\/td>\n<td>Constant IOPS load around 32 WOPS and 32 ROPS<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\">17<\/td>\n<td>Here the VMware snapshot is added, then IOmeter is restarted<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\">21<\/td>\n<td>IOmeter creating its testfile. Again, heavy writes. Note that host-level WOPS are now twice as high*<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\">30<\/td>\n<td>Testfile created, IOmeter starts performing its IOPS<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\">36<\/td>\n<td>The VM still performs the requested WOPS and ROPS. Note that host-level ROPS are twice as high**<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\">43<\/td>\n<td>Delete snapshot is called from VMware. Immediately the ROPS and WOPS shoot up<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\">46<\/td>\n<td>Note that the number of IOPS to and from the VM remain at quite a steady level<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\">52<\/td>\n<td>Host-level WOPS rise even further. This has to do with the first snapshot being gone now***<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\">60<\/td>\n<td>The snapshot is committed to the original VMDK. From now on, the VM performs exactly like before<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><em>Table 2: Events and action related to Graph 1<\/em><\/center><br \/>\n<em><b>Explanations:<\/b><\/em><br \/>\n*) The snapshot file is growing here. Obviously VMware needs twice as many writes to the filesystem in order to store all datablocks inside the empty (but now growing) snapshot.<\/p>\n<p>**) When reading from a snapshot, VMware first has to find out if the block resides in the base disk only, or that an updated version of the block\u00a0exists\u00a0\u00a0within the snapshot. This obviously requires twice the number of reads on the VM.<\/p>\n<p>***) The initial snapshot (which is 1 GByte in size) is now cleaned from disk. All of a sudden, the WOPS increase even further somewhat. To my knowledge, this has to do with the snapshot size. Previously the snapshot size was 1GByte, causing a lot of random reads over a larger part of the physical disks. This accounts for the hard disk head having to seek over a larger portion of the platter, delivering less IOPS. After the big snapshot file is gone, only a very small snapshot file remains. Now we get closer to track-to-track seeks (almost sequential IO patterns) which have a smaller head seek time, thus increasing the number of IOPS the disks deliver (for more info on this read <a href=\"http:\/\/vmdamentals.com\/?p=266\">Throughput part 1: The Basics<\/a>).<\/p>\n<p>Some very important things can be extracted from this: For starters, the simple fact of having a snapshot to a VM means that all ROPS of this VM grow with a factor 2 (!). On top of that, when the VM writes a block that was not written to the snapshot before you also need twice the WOPS on that VM. This is due to the fact that VMware has to update the table of &#8220;where to find what block&#8221; (snapshot or base disk). This impacts performance significantly!<\/p>\n<p>Secondly, the deletion of a snapshot simply shoots disk IOPS to the roof. In the test (look at samples 46..60) both the ROPS and WOPS went as high as the storage would go (there may be a clipped maximum to this, but that is beyond the performance of a set of 10K SAS drives in RAID1).<\/p>\n<p><BR><BR><strong>Performance impact on saturated disks<\/strong><\/p>\n<p>We have seen performance impact from using and deleting snapshots, but the impact on the VM itself was relatively small. So what happens if a set of disks is saturated by a VM and we start to use a snapshot? Check out the next graph:<br \/>\n<center><br \/>\n<img decoding=\"async\" class=\"aligncenter\" title=\"Snapshot impact with maxed-out IOPS\" src=\"http:\/\/vmdamentals.com\/wp-content\/uploads\/2011\/12\/Snapshot-impact-maxed-iops.png\" alt=\"Snapshot impact with maxed-out IOPS\" \/><br \/>\n<em>Graph 2: Maxed-out IOPS from a VM in conjunction with a snapshot<\/em><\/center>\n<\/p>\n<p><BR><br \/>\nIn this graph the VM saturates the disk it runs on (sample 11-21). IOmeter still performs equal ROPS and WOPS, but here we see the disks manage to perform twice as much ROPS. This is probably because the disk set is a RAID1 which has a write penalty of 1:2 (also see <a href=\"http:\/\/vmdamentals.com\/?p=296\">Throughput part 2: RAID types and segment sizes)<\/a>. Around sample 26 the VM is snapshotted. From sample 31-40 the test file is created which IOmeter will use.<\/p>\n<p>At sample 41 things get interesting; here we see the performance of the VM with a snapshot added to the VM. Because of the read overhead of having the snapshot, total performance here already drops by a factor 5 (!). At sample 51 the snapshot is deleted. Now VMware creates the second snapshot, and starts to commit the first snapshot into the base disk. At sample 61, we see a small glitch in IOPS; here the first snapshot is deleted, but the second snapshot has already grown too large. The result is, that snapshot number 3 is added to the VM while VMware commit the second one (since snapshot one was already comitted we effectively still have only two snapshots).<\/p>\n<p>But now VMware gets into trouble: Every time a snapshot is commited, the second snapshot has already grown larger than the inital one. This means VMware will be unable to commit the snapshot. At sample 100 I stop IOmeter. The pruple and green line go to zero (the VM performs no more IOPS), and a little while later at sample 128 the snapshot is successfully deleted from the VM. After the delete of the snapshot I restart IOmeter at sample 130.<\/p>\n<p><BR><BR><strong>Performance impact on saturated disks in detail<\/strong><\/p>\n<p>Looking at the previous graph, you can extract the performance impact from it. To clarify, I created a graph with the perfmon output only:<br \/>\n<center><br \/>\n<img decoding=\"async\" class=\"alignbottom\" title=\"Snapshot impact with maxed-out IOPS from VM point of view\" src=\"http:\/\/vmdamentals.com\/wp-content\/uploads\/2011\/12\/Snapshot-impact-detail.png\" alt=\"Snapshot impact with maxed-out IOPS from VM point of view\" \/><br \/>\n<em>Graph 3: Disk IOPS impact on a snapshotted VM<\/em><\/center>\n<\/p>\n<p><BR><br \/>\nHere you can cleary see the performance from the VMs perspective. Remember, the VM is trying to perform as many ROPS and WOPS it possibly can. At the beginning, the VM performs an impressive 510 ROPS and 250 WOPS simultaneously (sample 7-25). Then at sample 30 the snapshot is added. After creating the IOmeter testfile, performance settles at sample 43-49 at about 110 ROPS and 100 WOPS. Note the difference!<\/p>\n<p>Then I (try to) delete the snapshot at sample 50. Because the disks remain saturated, but VMware starts to throw in more reads and writes in order to commit the snapshot, overall IOPS remain the same but read takes another hit and falls all the way down to a poor 28 ROPS. If you compare this to the initial 510 ROPS,<em><strong> the VM ends up somewhere at 5.5% of its original read performance!!<\/strong><\/em><\/p>\n<p><BR><BR><strong>What can be done about performance impact?<\/strong><\/p>\n<p>The big question of course, is how can we prevent this impact, and keep running our VMs even with a snapshot (or a snapshot being deleted)? Actually there are several things youi can do:<\/p>\n<ol>\n<li>Increase the performance of your LUNs by adding more disks to it;<\/li>\n<li>Measure and spread the IOPS over your LUNs so that busy LUNs get quieter and quiet LUNs get busier;<\/li>\n<li>Create your snapshot files on a different LUN, either by moving the VM configuration files to that LUN or adding a line to the VM config file (*.vmx) like:<\/li>\n<\/ol>\n<p style=\"text-align: center;\"><em>workingDir=&#8221;\/vmfs\/volumes\/Datastore1\/vm-snapshots&#8221;<\/em><\/p>\n<p>The last one is possibly the best one yet: You could actually create a separate LUN just to put your snapshots on! If you are a heavy user of snapshots (or your backup solution is), you could even consider to add two solid-state disks in a RAID1 config, and put all snapshots on those!<\/p>\n<p><BR><BR><strong>What about linked clones?<\/strong><\/p>\n<p>My colleague (thanks Simon!) did a quick test on our VMware View environment. A linked clone Windows XP image was used, from which IOPS were performed using IOmeter. The IOPS were then measured using perfmon from within the VDI desktop, and on a host level (an unused SAN LUN was used to put the linked clone on which was measured from VMware). It turns out that linked clones behave just like &#8220;normal&#8221; VMs with a snapshot: reads double, and writes double too if the block to be written is not part of the snapshot yet.<\/p>\n<p><BR><BR><strong>Conclusion<\/strong><\/p>\n<p>Looking at the measurements above, the conclusion is obvious: A VM can have a snapshot and even a snapshot deleted without impact. We have to keep in mind that the disks the VM lies on must be able to deliver much more IOPS than it does regularly. So the statement that deleting a snapshot freezes the VM is not true, at least not in the setup of test 1.<\/p>\n<p>On the other hand, if a VM (almost) saturates a\u00a0disk set\u00a0IOPS-wise like in test 2, the impact of having and especially deleting a snapshot can be disastrous. In the test I managed to impact read\u00a0performance\u00a0of the VM to 5.5% of its original read performance!<\/p>\n<p>Deleting snapshots can take a long time as we know. In the tests it became clear that the time required to commit the snapshot is not just about the size of the snapshot file, but also about the maximum number of IOPS the disks can deliver where the snapshot and the base disk lie. Even the write rate of the VM during snapshot committing impacts the required time to clean up significantly.<\/p>\n<p>Not really visible in this blogpost, but I have run the tests on both vSphere and ESX3.5. The results were almost identical. In my tests, vSphere appeared to slightly faster on deleting the snapshot, and VM performance was impacted even less. Since the hardware both were running on were not 100% identical, I do not want to compare them too much; it is sufficient to state performance between ESX3.5 and vSphere is not significantly apart when looking at virtual disk snapshots.<\/p>\n<p>Preventing impacted performance in conjunction with snapshotting has proven to be possible. Things like spreading VM load across LUNs (&#8220;storage DRS&#8221; for LUNs using storage vmotion would be nice!) or creating the snapshot files on a different or even dedicated LUN\u00a0can help.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>It is certainly not unheared of &#8211; &#8220;When I delete a snapshot from a VM, the thing totally freezes!&#8220;. The strange thing is, some customers have these issues, others don&#8217;t (or are not aware of it). So what really DOES happen when you clean out a snapshot? Time to investigate! Test Setup So how do [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[98,24,39,49,97,632],"class_list":["post-332","post","type-post","status-publish","format-standard","hentry","category-vmware","tag-delete-snapshot","tag-esx","tag-performance","tag-snapshot","tag-vm-freezes","tag-vmware"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/www.vmdamentals.com\/index.php?rest_route=\/wp\/v2\/posts\/332","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.vmdamentals.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.vmdamentals.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.vmdamentals.com\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.vmdamentals.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=332"}],"version-history":[{"count":167,"href":"https:\/\/www.vmdamentals.com\/index.php?rest_route=\/wp\/v2\/posts\/332\/revisions"}],"predecessor-version":[{"id":3592,"href":"https:\/\/www.vmdamentals.com\/index.php?rest_route=\/wp\/v2\/posts\/332\/revisions\/3592"}],"wp:attachment":[{"href":"https:\/\/www.vmdamentals.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=332"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.vmdamentals.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=332"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.vmdamentals.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=332"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}