2010-07-20

Where to Place your VM Swap?

This one has been bothering me lately. Where do you place your Virtual Machine Swap files?

There are two options:

  1. In the Same Directory  as the VM
  2. In the Datastore specified by the host.

As you can see below.

image[3]

If you choose the second option then you can configure the swap location per host

image

Here comes my question.

Duncan Epping posted about the Impact of decisions… - for those that wanted to keep the vswp files on local VMFS datastores on their Hosts. Frank Denneman also wrote a post regarding this subject as well- Impact of host local VM swap on HA and DRS.

My question is as follows. When changing this you see (in both screenshots) a nice warning from VMware that this could degrade vMotion performance.

I take this to be true if you were moving the swapfile location to a local VMFS volume located on the ESX host. When initiating a vMotion - the vswp file will have to be copied to the other host's vswp location for the migration to complete.

But what about a different Datastore that is shared storage - but not the location of the virtual machine files?

This is actually specified as a one of NetApp's best practices (NetApp and VMware vSphere Storage Best Practices TR-3749) pg. 80.

image

Now why would you do this? If you look on the right - you will see one reason - no snapshots, which will save precious disk space. Second reason  - no replication is needed (unless of course this is a requirement)

Some say this is a risk - because if your datastore with the vswp files goes down then all your VM's go down, which in essence is true - but… Since in most cases the datastore is just another volume on the same storage array from which the VM's are running from - the chance of the vswp datastore failing is equal to that of the chance that VM's datastore will fail.

So my question at the end of the day. Is the warning still valid when you define a shared datastore - one which all the ESX hosts in that cluster can access?

There is of course a certain overhead needed to set this option on each ESX host in the cluster - but that is not (IMHO) so much of an issue.

Looking forward to your comments.

17 comments:

Sto Rage said...

We follow NetApp's recommendation of keeping the swap on a separate datastore. One other reason apart from "no snapshot" is deduplication.
Filesystem used saved %saved
/vol/vmswap/ 49GB 104GB 68%

Sudharsan said...

Yes . What you have mentioned is absolutlely right .We should be able to place it on a common datastore that is on a shared storage and everything should work fine . We also have the possibility of putting these swap on required RAID level to give a better performance in case ( rarity though ) these VMs Swap . Chances of a LUN failing is very rare and should not stop us from putting swap on a common storage .

Christopher Waltham said...

Given that vSphere 4.2 will be ESXi-only, will this affect users who transition from ESX to ESXi? If you're booting from USB or SAN then you won't *need* local disk, though you could presumably still use them if you wanted to.

Forbes Guthrie said...

Hi Maish,
I'd say the warning isn't valid. It does specifically state "A host specified datastore", so it's talking about copying the swapfile file from one local disk to another.
Forbes

Greg said...

I'd say for it to be unambiguous there almost needs to be 3 options in the first image. 1. Store with Virtual Machine 2. Store on a shared datastore 3. Store on local host datastore. The warning should only be on the third option. I'm not really sure that is possible though.

Steve Flanders said...

I have a couple of questions about the reasons listed in this article as to why you would do this:

The first reason was because of no snapshots, which will save precious disk space. How so? A VM with a swap file in the same directory as the VMDK takes up the same amount of space as the same VM with a swap file in a separate directory, no? Is the concern about filling a datastore?

The second reason was because no replication is needed. Do you mean, for example, no RAIDed disks are needed for the swap files? I ask because the article goes on to say if your datastore with the vswp files goes down then all of your VMs go down, which makes it seem like replication is needed.

Thanks for the clarification.

Rooooonny said...

The difference is because you don't want to snapshot and/or replicate transient data. This saves you bandwidth and diskspace on your secondary storage array.

Steve Flanders said...

Agreed. So why not snapshot without the "Snapshot the virtual machine's memory" option?

Maish said...

Hi Steve, the snapshots that are being referenced here are not ESX snapshots but the Storage Array snapshots.

Steve Flanders said...

Ah! That makes much more sense, thanks.

Jack Nelson said...

Any benefit or harm if 2 vSwap location is used within the cluster? (2 datastore volumes between 12 hosts cluster)

Maish said...

Thanks for the question Jack.

I would think this would become too complex from a management purpose - because you can only define one swap location per host - and in this case you have to go and manually set each hosts location. You will have to keep track of the split between the hosts - from a management standpoint - this will not scale well.

Doctair said...

I followed an older revision of Netapp's Best practice guide, separating the paging file from the VM on a separate datastore. So we have a VM datastore, Paging Datastore, and Vswap DataStore. The only draw back to this scenario you end up with a C:\ for OS and D:\ for Pagefile in Windows. I would agree with Forbes' comment that it probably only applies to the local store of a Host. If you are provisioning a large cluster, setting up the shared Datastore I think is easier. You create it and then apply it to all hosts in the Cluster from Vcenter.

I also think if you are following a guide that is "best practice" from both Vmware and the San Vendor then I would assume we could safely ignore the warning. Or perhaps we should get them to put a a disclaimer in the article to ignore Vmwares warnings..

Stacy Carter said...

I ran into this same question recently while considering TR-3749 and the design of a stretched cluster/metrocluster (between two geographical locations), I guess that means that there would need to be two swap file datastores per each cluster (one for the hosts at one locaiton, and one for the hosts at the other location)?  Is this really worth the extra complexity and risk that this adds? 

Arun Raju said...

How many swap datastores can be set for a cluster and how can we manually select a swap datastore during vMotioning a VM?

My environment has 4 swap datastores, each about 250 GB in size (FC LUNs) shared among the ESXi hosts at a cluster level and I would like to select a swap datastore which is least utilized automatically during vMotion. Is this possible?

Maish said...

Unfortunately what you are asking for is not possible.

You can choose either one of two options - in the same location as the VM - or in a swap location defined by the host.

Changing the Swap partition during vMotion can has effect on performance.

BrettM said...

It's not that much extra risk or complexity, and can be automated in host setup in various ways.  It's desirable because (presumably) your metro WAN link has less bandwidth than is available locally at either location and therefore you want to minimize traffic between the two sites.  For the same reason you'd also set up cluster DRS rules / VM affinities so they don't automatically vmotion between locations unless one location becomes unavailable or its resources become very strained compared to the other.