# Affinity Groups

HVM Clusters offer affinity groups and anti-affinity groups. These work similarly to affinity groups on other platforms, such as the affinity rules concept in VMware vSphere. An affinity group contains a type (either Keep Together or Keep Separate) and a list of servers which should have the rule applied. Whenever possible, servers configured to "Keep Together" will run on the same HVM Host. Servers configured to "Keep Separate" will be balanced across HVM Hosts to the maximum extent possible.

Viewing Affinity Groups

Affinity groups are listed on the Resources tab of the HVM Cluster detail page (Infrastructure > Clusters, then select the appropriate HVM Cluster). From the ACTIONS menu for each affinity group, they may be edited or deleted. By editing an affinity group, users may view or edit its enabled status (affinity groups which are not enabled will not be acted on).![A list of current-existing affinity groups.](https://support.hpe.com/hpesc/public/api/document/sd00008058en_us/GUID-C5C8E073-11BC-4D5A-A900-14571F77280D-high.png)

Adding Affinity Groups

As mentioned in the previous section, affinity groups are listed on the Resources tab of the HVM Cluster detail page (Infrastructure > Clusters, then select the appropriate HVM Cluster). From here, to create a new affinity group, click + ADD. Configure the following:

- **NAME:** A name for the affinity group
- **TYPE:** Select either "Keep Together" or "Keep Separate" to indicate whether the selected servers should run on as few or as many servers as possible within the capabilities of the HVM Cluster
- **ACTIVE:** When checked, the rules defined in the affinity group will be applied to the HVM Cluster
- **SERVERS:** Select as many servers as desired from the typeahead list

Once finished, click SAVE CHANGES. Following the next cluster sync, the affinity rule will be applied and VMs will begin to migrate (if applicable).

TIP

Placement settings (ex. pinning a VM to a specific host) can override an affinity group. HVM Clusters will attempt to implement affinity groups intelligently to work around VM placement. For example, in a group of five VMs configured to "keep together" with one pinned to host 1, the Cluster would run all five VMs on host 1 (if possible) to simultaneously honor the placement and the affinity group. In some scenarios, it will not be possible to simultaneously honor all placements and affinities/anti-affinities.

![Adding a new affinity group.](https://support.hpe.com/hpesc/public/api/document/sd00008058en_us/GUID-9C039E15-FE97-4CFD-987E-07A16E644534-high.png)

Adding Servers to Affinity Groups at Provision Time

In addition the adding servers from the affinity group, newly-provisioned servers may be added to an affinity group at provision time. From the CONFIGURE tab of the provisioning wizard, expand the Advanced Options section. Within Advanced Options, select an affinity group. The affinity group must be pre-existing and this list will be filtered to show only affinity groups that apply depending on other configuration parameters set on the new Instance.![Setting an affinity group on a new vmware instance at provision time](https://support.hpe.com/hpesc/public/api/document/sd00008058en_us/GUID-12E8B43B-9A47-46D9-8A99-3EBDF1FAD577-high.png)
