> For the complete documentation index, see [llms.txt](https://karansingh.gitbook.io/aws-saa-c02/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://karansingh.gitbook.io/aws-saa-c02/auto-scaling-groups-asg/overview.md).

# Overview

* It contains a **collection of Amazon EC2 instances that are treated as a logical grouping for the purposes of automatic scaling and management**.
  * An Auto Scaling group also **enables you to use EC2 Auto Scaling features such as health check replacements and scaling policies**.<br>

* The **size of an Auto Scaling group depends on the number of instances that you set as the desired capacity**.
  * You **can adjust its size to meet demand, either manually or by using automatic scaling**.

* An **Auto Scaling group starts by launching enough instances to meet its desired capacity**.

  * It **maintains this number of instances by performing periodic health checks on the instances in the group**.<br>
  * The Auto Scaling group **continues to maintain a fixed number of instances even if an instance becomes unhealthy**.
    * If an instance becomes unhealthy, **the group terminates the unhealthy instance and launches another instance to replace it**.

* You can **use scaling policies to increase or decrease the number of instances in your group dynamically to meet changing conditions**.

## CloudWatch Metrics

* A **CloudWatch metric represents a time-ordered set of data points**; it is **like a variable to monitor**, and the **data points as representing the values of that variable over time**.<br>
* You can **use these metrics to verify that your system is performing as expected** or **scale in or scale out your EC2 Instances depending on a certain metric**.

## Default Termination Policy

* The **default termination policy is designed to help ensure that your instances span Availability Zones evenly for high availability**.
  * The **default policy is kept generic and flexible to cover a range of scenarios**.<br>
* Within the selected Availability Zone, the **default termination policy behaviour is as follows**:<br>
  1. Determine which instances to terminate so as to **align the remaining instances to the allocation strategy** for the On-Demand or Spot Instance that is terminating. <br>
  2. Determine **whether any of the instances use the oldest launch template or configuration**.<br>
  3. After applying all of the above criteria, if there are multiple unprotected instances to terminate, determine **which instances are closest to the next billing hour**.
