# Module 10: Automatic Scaling and Monitoring
# Section 1: Load Balancing
:::info
* Distributes incoming app or network traffic across multiple targets in a single or multiples AZ
* Scales your load balance as traffic to your aapp changes over time
![](https://i.imgur.com/qUEq6yE.png)
:::
## Types of loads balancers
![](https://i.imgur.com/qaMGpPX.png)
## How Elastic Loas Balancing works
* With Application Load Balncers and Network Load Balancers, you **register targets in traffic to the target groups**
* With Classic Load Balancers, you *register instance with the load balancer*
* Load balancer performs health checks to monitor health of registered targets
![](https://i.imgur.com/DDry2vd.png)
## Elastic Load Balancing use cases
* High available and fault-tolerant app
* Containerized app
* Elasticity and scalability
* VPC
* Hybrid environments
* Incoke Lambad functions over HTTP(S)
## Load balancer monitoring
* **Amazon CloudWatch metrics**
* Used to verify that the system is performing as expected and creates an alarm to initiate an action if a metric goes outside an acceptable range
* **Access logs**
* Capture detailed information about requests sent to your load balancer
* **AWS CloudTrail logs**
* Capture the who, what, when, and where of API interactions in AWS services
# Section 2: Amazon CloudWatch
## Monitoring AWS resources
To use AWS efficiently, you need insight into your AWS resources:
* How do you know when you should *launch more Amazon EC2 instances ?*
* Is your *app's performance or availability* being affected by a lack of sufficient capacity ?
* How much of your infrastructure is actually *being used* ?
## Amazon CloudWatch
* Monitors
* AWS resources
* App that run on AWS
* Collect and track
* Standard metrics
* Custom metrics
* Alarms
* Send notifications to an Amazon SNS topic
* Perform Amazon EC2 Auto Scaling or Amazon EC2 actions
* Events
* Define rules to match changes in AWS environment and route these events to one or more target functions or streams for processing
## CloudWatch alarsm
* Create alarms basde on
* Static threshold
* Anomlay detection
* Metric math expression
* Specify
* Namespace
* Metric
* Statistic
* Period
* Conditions
* Additional configuration
* Actions
![](https://i.imgur.com/SP5DoTW.png)
# Section 3: Amazon EC2 Auto Scaling
## Why is scaling important ?
:::info
Scaling is the ability ot increase of decrease the compute capacity of your app.
:::
![](https://i.imgur.com/yLp2cmb.png)
* First graph: unused capacity on most days of the week, not cost optimized
* Second graph: under capacity on certain days
:::warning
Automatic capacity scaling is necessary to support the fluctuating demands for service.
:::
## Amazon EC2 Auto Scaling
* Hels you maintaint app
* Enables you to automatically add or remove EC2 instances according to conditions taht you define
* Detects impaired EC2 instances and unhealthy app, and replaces the instances without your intervention
* Provides several scaling options
* Manual
* Scheduled
* Dynamic (on-demand)
* Predictive
![](https://i.imgur.com/XFwCJ6g.png)
## Typical weekly traffic at Amazon.com
![](https://i.imgur.com/xm7oy5W.png)
## November traffic to Amazon.com
![](https://i.imgur.com/6wxUWLS.png)
## Auto Scaling groups
:::info
An **Auto Scaling group** is a collection of EC2 instances that are treated as a logical grouping for the purposes of automatic scaling and management.
![](https://i.imgur.com/KB6qQEF.png)
:::
## Scaling ou vs scaling in
![](https://i.imgur.com/6pccaGF.png)
## How Amazon EC2 Auto Scaling works
![](https://i.imgur.com/uWKP0lO.png)
## Implementing dynamic scaling
![](https://i.imgur.com/wMLgVn0.png)
## AWS Auto Scaling
* Monitors you app and automatically adjusts capacity to maintain steady, predictable performance at the lowest possible cost
* Provides a simple, powerful user interface that enables you to build scaling plans for resources, including
* Amazon EC2 instances and Spot Fleet
* Amazon Elastic Container Service (Amazon ECS) Tasks
* Amazon DynamoDB tables and indexes
* Amazon Aurora Replicas
# Wrap-up
Which service would you sue to send alerts base on Amazon CloudWatch alarms ?
1. Amazon Simple Notification Service
2. AWS CloudTrail
3. AWS Trusted Advisor
4. Amazon Route 53
:::spoiler Answer
Keywords:
* send alerts
* Amazon CloudWatch Alarms
Answer: 1.
:::