Managing Apache CloudStack Affinity Groups


To further reduce fault tolerance, running multiple instances serving your application/ service together with the load balancer feature provided from the virtual router in CloudStack, is recommended. In case you have multiple servers running your services, you can assign instances to an Affinity group in CloudStack. This keeps instances from the same Affinity group with rule "host anti-affinity" deployed on different hypervisors as much as possible. Should a host fail and your instance goes down, another instance on a different host serving the same content keeps working preventing your entire service from being unavailable.

Affinity groups can be attached to instances while creating the instance. You can change an Affinity group of an existing instance from the Instance Details tab. Make sure to stop the instance before changing the Affinity group.


Adding an Affinity Group

  1. From the left menu choose Compute Affinity Groups, click Add new Affinity Group.
  2. Provide a name, optionally the description and choose affinity type.

    Affinity typesDescription
    host anti-affinityCloudStack deploys instances on different hypervisors as much as possible.
    host affinityCloudStack deploys instances on same hypervisor as much as possible.

Adding an existing Instance to an Affinity group

  1. From the left menu choose Compute Instances, click on the instance name.

  2. Stop the instance, by clicking on Stop instance from the top right options.
  3. Click on Change Affinity, from the top right options.
  4. Select the Affinity group and confirm by clicking OK.
  5. Make sure to start up your instance again.

Get Support

Need Technical Support?

Have a specific challenge with your setup?

Create a Ticket