Wednesday, 9 September 2020

Auto scaling Alarms

  • It is possible to scale an ASG( Auto Scaling Group) based on CloudWatch alarms
  • An Alarm monitors a metric(such as Average CPU).
  • Metrics are computed for the overall ASG instances.
  • Based on the alarm:
  1. we can create scale-out policies (increase the number of instances).
  2. we can create scale-in policies (decrease the number of instances)
           
This post will hands-on for:

  1. Create CPU alarm for our ASG.
  2. Trigger above CPU alarm.
Let's get hands dirty:

Scale in:
  • Navigate to Auto scaling groups page --> scaling policies -->Add policy.

  • Click on Create a simple scaling policy.
    

  • Now click on Create new alarm.


Here i am provide inputs to get alarm, if the CPU utilization is above 50%,for at least 1 of 5 minutes.

Name of alarm is just description & Finally click on Create Alarm.


Conformation screen.


Automation:

Provide Name field info.
Take the action: here i'm add 2 instances if the alarm is triggered.(when ever the alarm triggered)
wait time: 60 sec
Finally click on create.


similarly we can create new alarm for scale out. here i am consider if the cpu utilization is less then 10 %. Remove 1 EC2 instance automatically.






No comments:

Post a Comment