# Configure a VM Auto Scaling Group

VM Auto Scaling Groups are a collection of virtual servers that automatically scale the number of VM replicas based on the metrics.

{% hint style="info" %}
**Note:**

* This process is limited to contract owners, administrators, and users with access rights to the data center hosting the VM Auto Scaling Group.
* Configuration of a VM Auto Scaling Group triggers the creation of two monitoring alarms for scale in and scale out operations according to the policy settings.
{% endhint %}

{% hint style="info" %}
**Prerequisites:**

* When provisioning a VM Auto Scaling Group, ensure that the necessary resources are available and that they are within the configured resource limits of your contract. To check the contract resource limits in DCD, see [<mark style="color:blue;">Resource Overview</mark>](../../../set-up-ionos-cloud/management/usage/resource-overview).
* IONOS recommends that you enable CloudInit or use existing images.
{% endhint %}

Follow these steps to configure a VM Auto Scaling , and define thresholds and scaling policies:

1\. In the **DCD**, go to **Menu** > **Network Services** > **Auto Scaling**.

2\. Click **Create** to create a group and define replicas.

![Create a group using the VM Auto Scaling Manager](https://1737632334-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MifAzdGvKLDTtvJP8sm%2Fuploads%2Fgit-blob-b28ac7c06b07d1a1f7d0c670f05336bae7a47f71%2Fcreate-vm-auto-scaling-group-button.png?alt=media)

3\. The **Create VM Auto Scaling Group** window displays the **Autoscaling Setup** and the **Replica Configuration** tabs.

![Creating VM Auto Scaling Groups](https://1737632334-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MifAzdGvKLDTtvJP8sm%2Fuploads%2Fgit-blob-0314b84be7aea96dead32324122d2e56f8378a2e%2Fcreate-vm-auto-scaling-group.png?alt=media)

4\. Define the following in the **Autoscaling Setup** tab:

* [<mark style="color:blue;">**Create a VM Auto Scaling Group**</mark>](#create-a-vm-auto-scaling-group)
* [<mark style="color:blue;">**Define Scaling Thresholds**</mark>](#define-scaling-thresholds)
* [<mark style="color:blue;">**Define Scaling In Policies**</mark>](#define-scaling-in-policies)
* [<mark style="color:blue;">**Define Scaling Out Policies**</mark>](#define-scaling-out-policies)

5\. Configure replicas. For more information, see [<mark style="color:blue;">Configure replicas</mark>](configure-vm-auto-scaling-replicas).

{% hint style="warning" %}
**Important:** The application applies a default replica setup if you do not configure replicas. Hence, we recommend that you configure replicas before you click **Create**. It is also mandatory, as the ALB uses the IP addresses of the NICs linked to the VM instances. Provisioning the replica defaults does not configure a network, thus, the associated ALB is left without NICs or IP addresses.
{% endhint %}

6\. Click **Create** to save the configuration.

{% hint style="success" %}
**Result:** Your VM Auto Scaling Group is successfully configured. You can now manage it via the VM Auto Scaling Manager.
{% endhint %}

![VM Auto Scaling Manager after successfully configuring a VM Auto Scaling Group](https://1737632334-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MifAzdGvKLDTtvJP8sm%2Fuploads%2Fgit-blob-04361f6690148ff1f49cc618558fba3f185fa9ad%2Fvm-auto-scaling-manager.png?alt=media)

## Create a VM Auto Scaling Group

You can specify a name for your VM Auto Scaling Group and the minimum number and the maximum number of VM instances it can contain during scaling. The minimum number ensures that you never run out of VM instances and the group always has at least one VM instance. The feature cannot provide more than the maximum number of VM instances during a scale out operation.

To create a VM Auto Scaling Group, go to the **Autoscaling Setup** tab in the **Create VM Auto Scaling Group** window and specify the following:

1\. **Name:** Enter a name for the VM Auto Scaling Group.

2\. **Data Center:** Select a data center from the drop-down list. You can either select an existing [<mark style="color:blue;">Virtual Data Center (VDC)</mark>](https://docs.ionos.com/support/general-information/glossary-of-terms#virtual-data-center-vdc) or create a new one if required. The application lists all the VDCs in your DCD. The group is valid only within the selected VDC to which it belongs.

3\. **Minimum Count:** Enter the minimum number of VMs the group must scale to. The minimum replica count is one. VM Auto Scaling uses this as a reference value to stop deleting VM instances for a group. This is necessary to ensure that scaling does not reduce the VM instances beyond the specified count.

4\. **Maximum Count:** Enter the maximum number of VMs the group must scale to. VM Auto Scaling uses this as a reference value to stop adding new VM instances for a group. This is necessary to ensure that scaling does not increase beyond the specified count. To improve the efficiency of the VM Auto Scaling service, we recommend limiting the maximum number of VMs in an Auto Scaling Group to 100 or less.

![Creating VM Auto Scaling Groups](https://1737632334-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MifAzdGvKLDTtvJP8sm%2Fuploads%2Fgit-blob-0314b84be7aea96dead32324122d2e56f8378a2e%2Fcreate-vm-auto-scaling-group.png?alt=media)

## Define Scaling Thresholds

A **Policy** defines the rules to trigger VM Auto Scaling to analyze the resource utilization rate at regular intervals. You can only define one metric policy per group that triggers the scaling process.

To define policies, go to the **Autoscaling Setup** tab in the **Create VM Auto Scaling Group** window and specify the following:

1\. **Metric:** Select a metric from the drop-down list whose performance must be monitored. The pre-defined values are based on the CPU utilization average or network bytes for incoming and outgoing bytes or packets.

2\. **Scale In Threshold:** Enter a value to specify when VM Auto Scaling must trigger the scale in operation. The value specified here indicates the percentage of the CPU utilization rate or the network packets or network bytes, based on which the scale in action is triggered for the metric. For example, if you specify the CPU utilization rate as 30, VM Auto Scaling automatically begins scaling inwards and deletes the additional VM instances when the CPU utilization rate is 30%.

3\. **Scale Out Threshold:** Enter a value to specify when VM Auto Scaling must trigger the scale out operation. The value specified here indicates the percentage of the CPU utilization rate or the network packets or bytes based on which the scale-out action is triggered for the metric. For example, if you specify the value as 70, the application automatically begins scaling outwards and adds additional VM instances when the CPU utilization rate reaches 70%.

{% hint style="warning" %}
**Note:** Ensure that the **Scale In Threshold** and the **Scale Out Threshold** field values differ by 40%. For example, if you set the **Scale In Threshold** to 15%, **Scale Out Threshold** cannot contain a value lesser than 55%.
{% endhint %}

4\. **Range:** Enter a time range in hours, minutes, or seconds. Example: 1h, 3m, 120s. It is the period during which VM Auto Scaling measures the percentage of chosen metric utilization at regular intervals and automatically scales in or scales out based on the demand. If specifying in seconds, ensure that the value is not less than 120 seconds.

5\. **Unit:** Select a unit from the drop-down list. You can specify whether the scaling process should be initiated every hour, minute, or second for other predefined metrics. This is automatically set to **Total** for an **instance CPU utilization average** metric.

![Defining scaling thresholds](https://1737632334-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MifAzdGvKLDTtvJP8sm%2Fuploads%2Fgit-blob-ec874291421b357ce4d44c81fcd0ab21e4c85e94%2Fcreate-vm-auto-scaling-group-threshold-policy.png?alt=media)

## Define Scaling In Policies

**Scale in** defines the action triggered during a scale in operation. Based on the values defined, the feature automatically deletes the specified number of VM instances after the cooldown period.

To define scale in policies, go to the **Autoscaling Setup** tab in the **Create VM Auto Scaling Group** window and specify the following:

1\. **Amount Type:** Select a value from the drop-down list to define the number of replicas that must be deleted. You can choose either **Percentage** or **Absolute**.

2\. **Amount:** Enter the number of VM instances to be deleted during a scale in operation. The minimum value is one. Scale in jobs with a large number of VMs may encounter performance issues. Hence, we recommend limiting the deletion of VMs to at most five, regardless of whether the **Amount Type** is **absolute** or **percentage**.

3\. **Cooldown Period:** Enter the cooldown period to indicate the interval between each auto scaling action in the group. The cooldown period can be measured in minutes, seconds, or hours. For example, when the value is set to 5m, the scale in action is activated every 5 minutes. VM Auto Scaling automatically deletes the given number of VM instances when the resource consumption is lower.

{% hint style="warning" %}
**Note:**

* Only one scaling action remains in progress for a VM Auto Scaling Group. The metric is reevaluated after the current scaling action completes.
* The minimum value is two minutes, and the maximum value is 24 hours.
* If specifying in seconds, ensure the minimum value is not less than 120 seconds.
* The application considers the default value of five when a period is not specified.
{% endhint %}

4\. **Termination Policy:** Select a value from the drop-down list to choose whether the oldest or the most recent replica must be deleted first. Choosing the **Oldest replica first** delegates the scaling process to delete the oldest replicas. Otherwise, choose the **Youngest replica first** to begin scaling by deleting the most recent replica.

5\. **Delete attached volumes:** Select a value from the drop-down list to indicate if the attached volumes must be deleted. Choose **Don’t delete** to retain the attached volumes; otherwise, choose **Delete**.

![Defining scale in policies](https://1737632334-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MifAzdGvKLDTtvJP8sm%2Fuploads%2Fgit-blob-9d9b3c1571f231efd2ece33663377869f1f589fc%2Fcreate-vm-auto-scaling-group-scale-in.png?alt=media)

## Define Scaling Out Policies

**Scale out** defines the action triggered during a scale out operation. The feature automatically adds the specified number of VM instances after the cooldown period based on the demand.

To define scaling out policies, go to the **Autoscaling Setup** tab in the **Create VM Auto Scaling Group** window and specify the following:

1\. **Amount Type:** Select a value from the drop-down list to define the number of replicas added when the metric utilization exceeds the specified amount. You can choose either **Percentage** or **Absolute**.

2\. **Amount:** Enter a number to indicate the number of VM instances that must be added. The minimum value is one. Scale out jobs with a large number of VMs may encounter performance issues. Hence, we recommend limiting the addition of VMs to at most five, regardless of whether the **Amount Type** is **absolute** or **percentage**.

3\. **Cooldown Period:** Enter the cooldown period to indicate the interval between each auto scaling process in the group. The cooldown period can be measured in minutes, seconds, or hours. For example, when the value is set to 5m, the scale out process is activated every 5 minutes. VM Auto Scaling automatically adds the given number of VM instances when the resource consumption is higher. The [<mark style="color:blue;">notes mentioned in scale in policies</mark>](#define-scaling-in-policies) are also applicable to scale out policies.

![Defining scale out policies](https://1737632334-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MifAzdGvKLDTtvJP8sm%2Fuploads%2Fgit-blob-c808a002f3823c18319b677840e3f3bc15b4ec08%2Fcreate-vm-auto-scaling-group-scale-out.png?alt=media)
