In-Guest Defragmentation – The Holy Grail For Best Performance?


In one of our internal mailing list, a question regarding in-guest defragmentation came up again. The right answer to this question is simple. It depends!

OK that’s fair, but it depends on what? Well mostly it depends on two things:

  1. what kind of storage device you store your virtual machines on. There are huge differences between a HP StorageWorks 2120 and an EMC Symmetrix V-MAX in terms of features and capabilities to improve the overall performances of the storage device.
  2. what kind of features you may leverage in your virtual environment. Features like thin provisioning, snapshot, data deduplication and replication either at the ESX host or storage device level.

Scenario #1:

You use enterprise class SAN/NAS devices. In such configuration with multiple hosts hitting the storage devices, it is very likely you have a random IO pattern. No worries, such storage devices are very smart and can deal with random IO pattern using techniques like IO coalescing, read-head mechanism, cache algorithm, RAID stripping, etc…

Storage devices such NetApp and its WAFL mechanism automatically fragments data to the disks. In a technical report called NetApp and VMware vSphere Storage Best Practices, page 78 it says:

Virtual machines stored on NetApp storage arrays should not use disk defragmentation utilities as the WAFL file system is designed to optimally place and access data at a level below the GOS file system

Leveraging features like thin provisioning, snapshot, data deduplication and replication may be impacted by an in-guest defragmentation.

The IO load generated by the defrag process running inside the virtual machine will negate the benefit of having thin disk by having the disk inflating. What’s the point of using thin disk if you bloat it with your in-guest defragmentation?

The same IO load will generate another huge amount of IO’s in the background and mess up with snapshots, growing them unexpectedly eventually reaching the same size as the parent disk, creating many SCSI locks as well, bloating latency. Why would you do that to your virtual machine?

If you’re doing replication to the other side of the earth, you may send a fair amount of extra bytes across your WAN link, eventually you end up saturating the link causing high latency and disconnections. You’re sure you want to get the network team on your back?

Scenario #2

Dumb DAS devices. You have set up a virtual environment with no shared storage array, using one disk or maybe a few disks in a RAID configuration. In that case, in-guest defragmentation could be an improvement or I should say a mitigation of the overall performance degradation of your DAS. Scott Drummond of vpivot.com published an interesting article called Windows Guest Defragmentation, Take Two demoing the benefits of in-guest defragmentation in a very specific storage configuration, that is a DAS!

Again even though you’re using a dumb DAS device, leveraging features like thin provisioning may actually render in-guest defragmentation inappropriate for the same reason I have enlighten in scenario #1.

You may attach the DAS with a smart SCSI controller with plenty of cache and able to do IO coalescing but at the end of the day defragmenting is about writes, many writes, generating many IO’s that neither the controller’s cache or the physical disks in the DAS can absorb efficiently.

Summary:

My thought is that in-guest defragmentation is, for most of the environments I worked in, just totally inappropriate and actually may decrease the overall performances. The overhead of running the defragmentation process is likely to be much more of a burden and outweigh the virtual benefit.

As usual it depends on YOUR environment and the way you’ve designed your storage, the features you have enabled, your functional requirements, etc…

In any case, and that is valid for both of my scenarios here, the easiest way to gain more performance out of your storage device is to align your VMs and your VMFS datastores to the storage device. VM alignment is critical, especially for Microsoft Windows prior Vista and 2008. Another way to improve IOs, is to disable in the guest the access time updates process in NTFS. And finally at the ESX host level, make sure your VMFS datastores are aligned by creating them through the vCenter Client.

About these ads

3 thoughts on “In-Guest Defragmentation – The Holy Grail For Best Performance?

  1. hi interesting thought

    just one question how do you disable the “is to disable in the guest the access time updates process in NTFS”?

    thanks a lot
    what about for people that run on top of ext3/ext4 o reiserfs

  2. Hi and thx for your comment.

    To disable Last Access timestamps

    Create or modify the following registry key on your VM:
    Key Name: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem
    Name: NtfsDisableLastAccessUpdate
    Type: REG_DWORD
    Value: 1

    Not recommended for file servers or backup software using incremental backups though.

    Read this excellent Microsoft paper available at http://msdn.microsoft.com/en-us/windows/hardware/gg463394

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s