Affinity and anti-affinity rules allow you to spread a group of virtual machines across different ESXi hosts or keep a group of virtual machines on a particular ESXi host.
An affinity rule places a group of virtual machines on a specific host so that you can easily audit the usage of those virtual machines. An anti-affinity rule places a group of virtual machines across different hosts, which prevents all virtual machines from failing at once in the event that a single host fails.
Affinity and anti-affinity rules are either required or preferred.
- Required rule
- If the affinity or anti-affinity rules cannot be satisfied, the virtual machines added to the rule do not power on.
- Preferred rule
- If the affinity or anti-affinity rules are violated, the cluster or host still powers on the virtual machines.
For example, if you have an anti-affinity rule between two virtual machines but only one physical host is available, a rule which is required (strong affinity) does not allow both virtual machines to power on. If the anti-affinity rule is preferred (weak affinity), both virtual machines are allowed to power on.