InterviewHubPRO
Section Overview
Q25

Question 25 of 65

Part 3: Compute, Containers & Serverless (21 - 35)

38%
AWS Cloud Architecture•Part 3: Compute, Containers & Serverless (21 - 35)

EC2 Auto Scaling Policies.

In Simple Words:

  • Target Tracking: Automatically adjusts capacity to maintain a specific target metric (e.g. keep average CPU at 60%).
  • Step Scaling: Increases or decreases instances in steps based on CloudWatch alarm thresholds.
  • Scheduled Scaling: Scales up or down based on predictable calendar events (e.g. scale up every weekday morning at 8 AM).
hcl
# Auto Scaling Target Tracking Policy: Keep average CPU at 60%:
resource "aws_autoscaling_policy" "cpu_target" {
  name                   = "cpu-target-tracking"
  autoscaling_group_name = aws_autoscaling_group.app_asg.name
  policy_type            = "TargetTrackingScaling"

  target_tracking_configuration {
    predefined_metric_specification {
      predefined_metric_type = "ASGAverageCPUUtilization"
    }
    target_value = 60.0
  }
}