To create a VM-host affinity rule, select the desired cluster in the vSphere Web Client. Click Manage DRS rule > > settings > Add. Name your new rule, and then select Virtual Machines to Hosts from the Type drop-down menu. Select the desired virtual machine DRS group to which you want to apply your rule. Then select an affinity or anti-affinity type, save your changes, and implement the rule. Some of you may think, what if I want some virtual machines to run a group of hosts? Well, that`s where VMware DRS rules come in. DrS rules allow you to group your virtual machines and hosts that are in the same vSphere HA cluster and specify which ones to run on which hosts. Click Verify and repeat these steps for the other two VSAs. You should end up with three different rules, as follows: An affinity or anti-affinity rule establishes a relationship between a virtual machine and a host by requiring the hypervisor to retain or disconnect certain entities to balance traffic and workloads on available hosts. There are “mandatory” (mandatory) and “preferential” (should) rules.
We have seen a VM-VM affinity rule that specifies the affinity between individual virtual machines. However, a VM-Host affinity rule can define an affinity relationship between a group of virtual machines and a group of hosts. Using binding affinity rules can sometimes also help control licensing costs. There are application providers that use a host-level licensing model that requires that each host server that may host the application be licensed. Therefore, creating a small group of hosts and configuring an affinity rule so that the application server can only run on hosts in that group would help the organization avoid the cost of licensing additional hosts to run the application. There`s no way to enable both if they conflict – If two VM-VM affinity rules are in conflict, you can`t just enable both. For example, you can use a rule that keeps two virtual machines together and another rule that keeps the same two virtual machines separate on two different hosts. You cannot enable both rules. The system does not allow you to do this.
You must select one of the rules to apply and disable or delete the other that is causing the conflict. Smart if you ask me. Hypervisors allow IT administrators to have affinity between vCPUs and virtual machines. VCPU affinity refers to the hyper-threading of your processors, which keeps processors busy when they are otherwise idle. You can use affinity and anti-affinity to manage vCPU distribution. Excellent article Frank, it is interesting to see how binding rules can limit and influence HA/DRS, and we should make sure that this is taken into account in our designs. Carry on!! When you apply affinity rules, determine where to restart a virtual machine in your datacenter. Consider the specific storage, networking, and compute requirements of a virtual machine, as well as access to other associated virtual machines. Apply rules that enforce virtual machine placement behavior. While I don`t dispute the logic behind this idea, there are situations where it makes sense to use mandatory VM-host affinity rules. For example, a shared environment may be contractually required to separate the resources of specific tenants. For example, if a hosting provider hosts virtual machines for Coke and Pepsi, those virtual machines will likely need to be kept in different host groups to prevent them from being hosted on a shared VMware host.
The logic behind creating preferred VM-host affinity rules is that in situations where the required hardware resources are not available within a host group, it is better to run virtual machines in a different host group than to experience a failure. If a conflict conflicts, you can simply edit or disable a conflicting rule to keep your environment running smoothly. Be aware of limitations and issues when configuring affinity and anti-affinity rules. I`ve sometimes heard VMware administrators say that VM-host affinity rules should always be preferred, not mandatory. The reason is simple. For example, suppose one of the hosts in a host group goes down or is taken offline for maintenance, and the remaining hosts in the host group do not have sufficient resources to fully absorb the virtual machines running on the host that is now offline. If the virtual machine host affinity rule requires that these virtual machines run only on hosts within the specified host group, the rule prevents at least some of the virtual machines from running, even if hardware resources are available in other host groups.