# Autoscaling Groups (ASG)

Configure Autoscaling Groups (ASG) to ensure the application load is scaled based on the number of EC2 instances configured. Autoscaling detects unhealthy instances and launches new EC2 instances. ASG is also cost-effective as EC2 Instances are dynamically created per the application requirement within minimum and maximum count limits.

{% hint style="info" %}
For cluster autoscaling, [enable the Cluster Autoscaler option](https://docs.duplocloud.com/docs/automation-platform/overview/use-cases/creating-an-infrastructure-and-plan-for-aws/kubernetes-cluster/enable-cluster-autoscaler) in your Infrastructure before creating an ASG.
{% endhint %}

## Creating Autoscaling Groups (ASG)

1. In the DuploCloud Portal, navigate to **Cloud Services** -> **Hosts**.
2. In the **ASG** tab, click **Add**. The **Add ASG** page is displayed.<br>

   <figure><img src="https://2471407984-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F68cb0s9ce5UIUKWPuYs8%2Fuploads%2FxzalHDFfx9sz0uzBfN9i%2FScreenshot%20(30).png?alt=media&#x26;token=9059aa9e-ad0f-42bb-8b92-f72378d3ea0c" alt=""><figcaption><p><strong>Add ASG page</strong> with <strong>Use for Cluster Autoscaling</strong> enabled</p></figcaption></figure>
3. In the **Friendly Name** field, enter the name of the ASG.
4. Select **Availability Zone** and **Instance Type**.
5. In the **Instance Count** field, enter the desired capacity for the Autoscaling group.
6. In the **Minimum Instances** field, enter the minimum number of instances. The Autoscaling group ensures that the total number of instances is always greater than or equal to the minimum number of instances.
7. In the **Maximum Instances** field, enter the maximum number of instances. The Autoscaling group ensures that the total number of instances is always less than or equal to the maximum number of instances.
8. Optionally, select **Use for Cluster Autoscaling**.
9. Select **Advanced Options**. The **Advanced Options** section displays.<br>

   <figure><img src="https://2471407984-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F68cb0s9ce5UIUKWPuYs8%2Fuploads%2FKUWssOuFx2LuI0FWkcvI%2FScreenshot%20(32).png?alt=media&#x26;token=158a97bb-9250-490d-beba-8836d9afb5a7" alt=""><figcaption><p>The <strong>Add ASG Advanced Options</strong></p></figcaption></figure>
10. Fill in additional fields as needed for your ASG.
11. Click **Add**. Your ASG is added and displayed in the **ASG** tab.

<figure><img src="https://2471407984-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F68cb0s9ce5UIUKWPuYs8%2Fuploads%2FcibqENR2iFPwGXSOGXQN%2FScreenshot%20(33).png?alt=media&#x26;token=33565ffa-dcab-4859-8e19-8a571a1b8f38" alt=""><figcaption><p>The <strong>Add ASG</strong> page</p></figcaption></figure>

3. In the **Friendly Name** field, enter the name of the ASG.
4. Select **Availability Zone** and **Instance Type**.
5. In the **Instance Count** field, enter the desired capacity for the Autoscaling group.
6. In the **Minimum Instances** field, enter the minimum number of instances. The Autoscaling group ensures that the total number of instances is always greater than or equal to the minimum number of instances.
7. In the **Maximum Instances** field, enter the maximum number of instances. The Autoscaling group ensures that the total number of instances is always less than or equal to the maximum number of instances.
8. Optionally, select **Use for Cluster Autoscaling**.
9. Optionally select **Advanced Options,** and complete additional fields as needed.<br>

   <figure><img src="https://2471407984-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F68cb0s9ce5UIUKWPuYs8%2Fuploads%2F0IrQ3u6ic0fjpzdKmm5E%2Fasg3.png?alt=media&#x26;token=00eef080-8891-4935-9226-a94bdb2da5ad" alt=""><figcaption><p>ASG <strong>Advanced Options</strong></p></figcaption></figure>
10. Click **Add**. Your ASG is added and displayed in the **ASG** tab.

## Viewing Hosts in Autoscaling Groups

To view the hosts in an Autoscaling group, follow these steps:

1. In the DuploCloud Portal, navigate to **Cloud Services** -> **Hosts**.
2. Select the **ASG** tab.
3. In the **NAME** column, select the ASG for which you want to view Hosts.
4. Select the **Hosts** tab. A list of individual Hosts displays.

<figure><img src="https://2471407984-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F68cb0s9ce5UIUKWPuYs8%2Fuploads%2FPwqo3ozSS05XBvQ5mmCp%2Fscreenshot-nimbusweb.me-2024.02.18-13_52_12.png?alt=media&#x26;token=20e49199-fb57-45c8-94d0-26a0401720ff" alt=""><figcaption><p>The <strong>Hosts</strong> tab on the <strong>ASG Details</strong> page</p></figcaption></figure>

## **Creating an Amazon EC2 Autoscaling Policy**

Refer to AWS [Documentation](https://docs.aws.amazon.com/autoscaling/ec2/userguide/as-scale-based-on-demand.html#as-how-scaling-policies-work) for detailed steps on creating Scaling policies for the Autoscaling Group.
