# ASG

### What’s an Auto Scaling Group?

• In real-life, the load on your websites and applications can change

• In the cloud, you can create and get rid of servers very quickly

• The goal of an Auto Scaling Group (ASG) is to:

* Scale-out (add EC2 instances) to match an increased load
* Scale in (remove EC2 instances) to match a decreased load
* Ensure we have a minimum and a maximum number of machines running&#x20;
* Automatically register new instances to a load balancer
* Replace unhealthy instances

• Cost Savings: only run at an optimal capacity (principle of the cloud)

### Auto Scaling Group in AWS

#### Without Load Balancer

<figure><img src="/files/WdtapxgCU2d3fHuhQE3d" alt=""><figcaption></figcaption></figure>

#### With Load Balancer

<figure><img src="/files/leaMFUXIUcamEGGMdlEy" alt=""><figcaption></figcaption></figure>

### Scaling Strategies

• **Manual Scaling:** Update the size of an ASG manually&#x20;

• **Dynamic Scaling:** Respond to changing demand

* **Simple / Step Scaling**
  * When a CloudWatch alarm is triggered (example CPU > 70%), then add 2 units&#x20;
  * When a CloudWatch alarm is triggered (example CPU < 30%), then remove 1
* **Target Tracking Scaling**
  * Example: I want the average ASG CPU to stay at around 40%
* **Scheduled Scaling**
  * Anticipate a scaling based on known usage patterns&#x20;
  * Example: increase the min. capacity to 10 at 5 pm on Fridays

• **Predictive Scaling**

* Uses Machine Learning to predict future traffic ahead of time
* Automatically provisions the right number of EC2 instances in advance

• Useful when your load has predictable time-based patterns

<figure><img src="/files/fgtyTBYdKNJqgcqdZssz" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://huy312100.gitbook.io/software-development/cloud-service/aws/certificate/clf-c02/cloud-technology-and-services/elb-and-asg/asg.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
