VMware ESXi and vSphere Cluster Management

Create a VMware vSphere DRS VM Anti-Affinity Rule

Learn how to create, verify, and troubleshoot a VMware vSphere DRS VM-VM anti-affinity rule that keeps selected VMs on separate ESXi hosts.

A VMware vSphere Distributed Resource Scheduler (DRS) VM-VM anti-affinity rule directs DRS to avoid placing selected virtual machines on the same ESXi host. Separating related workloads can reduce the impact of a single host failure.

This procedure is performed in vCenter Server on a DRS-enabled cluster. It does not separate virtual machines across different clusters.

What a DRS VM-VM Anti-Affinity Rule Does

vSphere DRS is a cluster service that evaluates workload placement and resource balance. A VM-VM anti-affinity rule adds a placement constraint: the listed virtual machines should run on different ESXi hosts.

Common use cases include:

  • Separating redundant web or application servers.
  • Keeping clustered application nodes in different host failure domains.
  • Separating primary and replica servers when both must remain available during a host outage.
  • Placing paired infrastructure appliances on different hosts.

For example, a rule containing Web-01 and Web-02 tells DRS not to place both VMs on one host when suitable alternatives are available.

How DRS Applies the Rule

After a rule is saved, DRS evaluates the current placement of the protected VMs and the available hosts. Depending on the cluster's DRS automation settings, DRS may:

  • Place a VM on a different host during initial placement or power-on.
  • Recommend a live migration when both VMs are on the same host.
  • Perform a vMotion migration automatically when automation permits it.

vMotion is the live migration of a running VM between compatible ESXi hosts. A DRS recommendation is a suggested placement or migration action; it is not necessarily an action that has already occurred.

A rule can be configured but temporarily unsatisfiable. For example, if a two-host cluster loses one host, only one eligible host may remain. The rule still exists, but the cluster cannot currently place both VMs on separate hosts. Rule compliance must therefore be checked after failures, maintenance, manual migrations, and capacity changes.

DRS Rule Type Comparison

Rule typePlacement goalTypical use caseExample
VM-VM anti-affinityPrefer or require selected VMs to run on different hosts, according to the rule behavior exposed by the vSphere versionSeparate redundant servers or cluster nodesKeep AppNode-A and AppNode-B apart
VM-VM affinityPrefer selected VMs to run together on the same hostKeep tightly communicating VMs close togetherPlace a service VM and its helper VM together
VM-host placement ruleControl which hosts a VM or VM group may or should useKeep a workload on a host group or away from specific hostsAllow a VM group to run only on designated hosts

Do not select a VM-VM affinity rule when the goal is separation. A VM-host rule is also a different control: it relates VMs to hosts, not one VM to another.

Prerequisites and Planning

DRS is managed through vCenter Server, not directly from an individual ESXi host. Before creating the rule, identify the VM pair or group that must not share host hardware and review the following conditions.

RequirementWhy it mattersHow to verify
DRS enabledRules are cluster-level DRS featuresSelect the cluster and review its DRS configuration
Two or more eligible hostsSeparation requires an alternate hostCheck that at least two connected, compatible hosts can run the VMs
VMs in the same clusterA VM-VM rule applies within one DRS clusterConfirm both VMs appear under the same cluster inventory object
vMotion readinessDRS may need to migrate a running VMVerify compatible CPU, networking, storage access, and vMotion configuration
Sufficient capacityThe alternate host needs enough CPU and memoryReview host demand, reservations, admission controls, and available capacity
No conflicting rulesConflicting placement objectives can prevent separationReview affinity, anti-affinity, VM-host rules, host groups, and maintenance states

Also verify that the vSphere licensing and permissions in the environment support DRS and the required migration operations. For background on preparing a vMotion network, see Create Virtual Switch and VMkernel Port Group for vMotion. For permission issues, see Assign Permissions.

Create the VM-VM Anti-Affinity Rule

Exact labels can vary between vSphere versions, but the workflow is generally:

  1. Open the vSphere Client and select the target DRS cluster in the vCenter inventory.
  2. Open the cluster's Configure or Manage view.
  3. Open Settings, then locate DRS Rules.
  4. Select Add or the command to create a new DRS rule.
  5. Enter a meaningful name, such as Separate redundant web servers.
  6. Select the VM-VM anti-affinity rule type. Do not select VM-VM affinity or a VM-host rule.
  7. Use the VM selection control to add every virtual machine that must be separated.
  8. Review the membership and rule behavior, then save the rule.
  9. Confirm that the new rule appears in the cluster's DRS rules list and is enabled as intended.
Cluster inventory object > Configure or Manage > Settings > DRS Rules > Add

Use names that describe both the protected workload and the reason for separation. For example, Separate AppNode-A and AppNode-B - production redundancy is more useful than Rule 1.

Verify Rule Behavior

  1. Check the current host location of each protected VM. The VMs should be on different eligible ESXi hosts when the rule is satisfiable.
  2. Open the cluster's monitoring view and locate the vSphere DRS recommendations, migrations, or placement status.
  3. If both VMs initially run on one host, look for a recommendation to migrate one VM to another eligible host.
  4. Confirm whether the cluster's automation level performed the migration or whether an administrator must approve it.
  5. After a DRS action, manual vMotion, host maintenance operation, or host recovery, check the VM locations and rule compliance again.
Cluster inventory object > Monitor > vSphere DRS

A compliant state means the VM placement meets the configured rule. A noncompliant state does not necessarily mean the rule is misconfigured; it may indicate that no eligible alternate host exists or that another constraint prevents migration.

Rule Management Lifecycle

Edit membership or the rule name

Open the cluster's DRS rules list, select the rule, and choose the edit action. Update the name or add and remove VM members as the workload design changes. Recheck compliance after saving.

Disable, remove, or recreate a rule

Temporarily disable a rule when an approved operational exception is needed. Remove it when the protected workloads are retired or the design no longer requires separation. Recreate the rule if its purpose, membership, or placement behavior needs a clean redesign.

Document the business reason, protected workload relationship, owner, and expected failure-domain objective. This helps prevent accidental removal during VM migrations or application changes.

Limitations and Operational Considerations

  • A two-host cluster can satisfy separation only while both hosts are available and eligible.
  • If a host fails or enters maintenance mode, the remaining host may be the only valid destination. The rule cannot create a new failure domain by itself.
  • Insufficient CPU or memory, incompatible CPUs, unavailable storage, incompatible networking, attached devices, or other vMotion limitations can block a migration.
  • Affinity rules, other anti-affinity rules, VM-host rules, host groups, maintenance state, and admission or resource constraints can compete with the desired placement.
  • Some vSphere versions expose a choice between a softer preference and a more mandatory placement requirement. A soft preference can be relaxed when necessary; a mandatory behavior can make placement or migration fail rather than violate the requirement. Confirm the behavior and available options in the installed version.
  • Anti-affinity reduces the chance of losing all protected VMs to one host failure, but it does not protect against a cluster-wide outage or an application failure.

For broader availability planning, distinguish DRS placement from vSphere High Availability. DRS balances and places workloads; HA restarts eligible VMs after host failure. Related admission-control planning is covered in Admission Control Explained and Admission Control Policy.

Troubleshooting

The option to create a DRS rule is unavailable

  • Possible causes: An individual ESXi host is selected instead of a cluster; DRS is disabled; the account lacks cluster configuration privileges; or licensing and product feature requirements are not met.
  • Resolution: Select the vCenter-managed cluster, verify DRS configuration and feature availability, and validate the administrator's permissions.

Both protected VMs remain on the same host

  • Possible causes: No alternate host is eligible, spare capacity is insufficient, vMotion is blocked, DRS requires recommendation approval, or another placement rule conflicts with anti-affinity.
  • Resolution: Review rule compliance and DRS recommendations. Check host capacity, CPU and VM compatibility, storage and networking, device constraints, maintenance state, and conflicting rules. If appropriate, apply an approved migration manually.

The rule becomes noncompliant during maintenance or after a host failure

  • Possible causes: Only one suitable host remains, or remaining hosts are restricted by capacity, compatibility, or VM-host rules.
  • Resolution: Restore an eligible host or add capacity, review any temporary exception, and recheck placement after hosts return to service.

The wrong rule type was configured

  • Possible causes: A VM-VM affinity rule was selected, which encourages co-location, or a VM-host rule was selected when the goal was separation between VMs.
  • Resolution: Compare the configured type with the placement goal. Edit or replace the rule with a VM-VM anti-affinity rule and verify the VM membership.

Exam-Relevant Notes

  • A VM-VM anti-affinity rule separates selected VMs across ESXi hosts within the same DRS cluster.
  • A VM-VM affinity rule has the opposite goal: keeping selected VMs together.
  • A VM-host rule controls VM placement relative to host groups and is not a VM-to-VM separation rule.
  • DRS may recommend or perform vMotion, but the rule is not guaranteed to be satisfiable when no eligible host exists.
  • Always distinguish a configured rule from current rule compliance.