Affinity is a setting that can be made on a group of VMs where the cluster will try to keep the VMs on the same Hyper-V host. Anti-Affinity is a setting that can be made on a group of VMs where the cluster will try to keep the VMs on separate Hyper-V hosts. When using clustered configurations of SQL Server – both Always On Availability Groups (AGs) and Always On Failover Cluster Instances (FCIs) – the goal is to ensure availability. Ensure that no virtual node of a WSFC is running on the same host by using anti-affinity rules at the Hyper-V cluster level. If both members of an HA solution reside on the same physical host, and that host fails, the application-level HA solution is useless as all members are now offline, pending a Hyper-V cluster-level restart operation. For more details on affinity options for the VMs, see the topic “Cluster affinity” at Microsoft Learn.
Anti-affinity also affects Live and Quick Migration. The policies set in the anti-affinity rule can limit the placement of a VM. If the target of a migration places a VM onto a host with another VM, the anti-affinity rule will prevent the migration from occurring. Keep these rules in mind when designing your VM architecture as it may impact the total number of hosts you need.