Skip to content

Instances Anti-Affinity/Affinity

Multiple instances of the same service or application should be deployed in different availability zones to avoid service disruption in case of an infrastructure outage. When this isn't possible or isn't enough to guarantee your application availability you can use an anti-affinity schedule policy. An affinity policy is also available.

Create a server group

First you need to create a "server group". The server group will contain all the instances to which you want to apply an anti-affinity/affinity policy.

$ openstack server group create --policy <policy> <name>


  • policy : Add a policy (‘affinity’ or ‘anti-affinity’, defaults to ‘affinity’)
  • name : New server group name

If you want all the instances to be hosted on different compute nodes, create a server group with an anti-affinity policy. Otherwise use an affinity policy.

You can see your server groups with:

$ openstack server group list [--long]

Create an instance and apply a schedule policy

To add an instance to a server group, use the following extra option when creating a new instance.

--hint group=<server_group_uuid>


$ openstack server create --image <image_uuid> --flavor <flavor_name> --hint group=<server_group_uuid> <new_instance_name>


  • You can only add an instance to a server group at instance creation time. Not afterwards!
  • When using an affinity policy you are limited to the resources available in the compute node where the first instance was scheduled.

Other useful operations:

Display server group details

$ openstack server group show <uuid>

Delete a server group

$ openstack server group delete <uuid>