Bird
Raised Fist0
AWScloud~10 mins

ECS service auto scaling in AWS - Step-by-Step Execution

Choose your learning style10 modes available
Process Flow - ECS service auto scaling
Start: ECS Service Running
↓
Monitor Metrics (CPU, Memory)
↓
Check if Metric > Scale Out Threshold?
No→Check if Metric < Scale In Threshold?
↓
Increase Desired Task Count
↓
Update ECS Service Desired Count
↓
Wait for Stabilization
↓
Repeat Monitoring
The ECS service auto scaling monitors resource metrics and adjusts the number of running tasks by increasing or decreasing desired count based on thresholds.
Execution Sample
AWS
1. Monitor CPU usage
2. If CPU > 70%, increase tasks by 1
3. If CPU < 30%, decrease tasks by 1
4. Update ECS service desired count
5. Wait and repeat
This process automatically adjusts ECS tasks based on CPU usage thresholds.
Process Table
StepCPU Usage (%)ConditionActionDesired Task CountNotes
15050 > 70? No; 50 < 30? NoNo scaling2Initial state, no change
27575 > 70? YesScale out +13Increased tasks due to high CPU
38080 > 70? YesScale out +14Further increase tasks
46565 > 70? No; 65 < 30? NoNo scaling4CPU normal, no change
52525 < 30? YesScale in -13Decreased tasks due to low CPU
62020 < 30? YesScale in -12Further decrease tasks
73535 > 70? No; 35 < 30? NoNo scaling2CPU normal, no change
85050 > 70? No; 50 < 30? NoNo scaling2Stable state
9ExitReached stable desired countStop scaling2Scaling stabilized
💡 Scaling stops when CPU usage is stable and desired task count matches load.
Status Tracker
VariableStartAfter Step 1After Step 2After Step 3After Step 4After Step 5After Step 6After Step 7After Step 8Final
CPU Usage (%)50507580652520355050
Desired Task Count2234432222
Scaling ActionNoneNoneScale Out +1Scale Out +1NoneScale In -1Scale In -1NoneNoneNone
Key Moments - 3 Insights
Why does the desired task count not change when CPU usage is 50%?
Because 50% CPU is between the scale out threshold (70%) and scale in threshold (30%), so no scaling action is taken as shown in step 1 of the execution table.
What happens when CPU usage is above 70% multiple times in a row?
The desired task count increases by 1 each time CPU is above 70%, scaling out the service, as seen in steps 2 and 3.
Why does scaling stop at the end?
Scaling stops when CPU usage stabilizes within thresholds and desired task count matches the load, indicated by 'Exit' in step 9.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution table, what is the desired task count after step 3?
A2
B4
C3
D5
💡 Hint
Check the 'Desired Task Count' column at step 3 in the execution table.
At which step does the CPU usage first trigger a scale in action?
AStep 6
BStep 4
CStep 5
DStep 7
💡 Hint
Look for the first 'Scale in -1' action in the 'Scaling Action' column.
If the scale out threshold was lowered to 60%, how would the action at step 4 change?
AScale out +1
BScale in -1
CNo change, still no scaling
DStop scaling
💡 Hint
At step 4 CPU is 65%, which is above 60%, so scaling out would occur.
Concept Snapshot
ECS Service Auto Scaling:
- Monitors resource metrics (CPU, Memory)
- If metric > scale out threshold, increase desired tasks
- If metric < scale in threshold, decrease desired tasks
- Update ECS service desired count accordingly
- Wait for stabilization before next check
Full Transcript
ECS service auto scaling works by monitoring resource usage like CPU. When CPU goes above a set high threshold, it increases the number of running tasks to handle more load. When CPU drops below a low threshold, it decreases tasks to save resources. This process repeats continuously to keep the service responsive and efficient. The execution table shows CPU values and scaling actions step by step, with the desired task count adjusting up or down. Scaling stops when CPU stabilizes within thresholds and the task count matches the load.

Practice

(1/5)
1. What is the main purpose of ECS service auto scaling?
easy
A. Store container logs for analysis
B. Manually start and stop containers
C. Automatically adjust the number of running containers based on demand
D. Create new ECS clusters automatically

Solution

  1. Step 1: Understand ECS service auto scaling function

    ECS service auto scaling changes the number of containers automatically to match workload.
  2. Step 2: Compare options to this function

    Only Automatically adjust the number of running containers based on demand describes automatic adjustment of container count based on demand.
  3. Final Answer:

    Automatically adjust the number of running containers based on demand -> Option C
  4. Quick Check:

    Auto scaling adjusts container count = Automatically adjust containers [OK]
Hint: Auto scaling means automatic container count changes [OK]
Common Mistakes:
  • Confusing auto scaling with manual container management
  • Thinking auto scaling creates clusters
  • Believing auto scaling stores logs
2. Which of the following is the correct way to specify a target tracking scaling policy for CPU utilization in ECS service auto scaling?
easy
A. "TargetValue": 50, "PredefinedMetricSpecification": {"PredefinedMetricType": "ECSServiceAverageCPUUtilization"}
B. "TargetValue": "high", "PredefinedMetricSpecification": {"PredefinedMetricType": "CPUUsage"}
C. "TargetValue": 100, "MetricName": "MemoryUtilization"
D. "TargetValue": 30, "PredefinedMetricSpecification": {"PredefinedMetricType": "NetworkIn"}

Solution

  1. Step 1: Identify correct metric type for CPU utilization

    The predefined metric for ECS CPU is "ECSServiceAverageCPUUtilization" with a numeric target value.
  2. Step 2: Check option syntax and metric correctness

    "TargetValue": 50, "PredefinedMetricSpecification": {"PredefinedMetricType": "ECSServiceAverageCPUUtilization"} uses correct metric type and numeric target value 50, which is valid.
  3. Final Answer:

    "TargetValue": 50, "PredefinedMetricSpecification": {"PredefinedMetricType": "ECSServiceAverageCPUUtilization"} -> Option A
  4. Quick Check:

    Correct metric and numeric target = "TargetValue": 50, "PredefinedMetricSpecification": {"PredefinedMetricType": "ECSServiceAverageCPUUtilization"} [OK]
Hint: Use numeric target and correct predefined metric name [OK]
Common Mistakes:
  • Using string instead of number for TargetValue
  • Using wrong metric names like CPUUsage
  • Mixing memory or network metrics for CPU scaling
3. Given this ECS service auto scaling configuration snippet:
{"MinCapacity": 2, "MaxCapacity": 5, "TargetValue": 60}

What happens when CPU utilization stays at 70% for a long time?
medium
A. The service scales up to 5 containers to reduce CPU load
B. The service scales down to 2 containers to save cost
C. The service keeps running 2 containers without change
D. The service crashes due to high CPU

Solution

  1. Step 1: Understand scaling triggers from CPU target

    TargetValue 60 means ECS tries to keep CPU near 60%. If CPU is 70%, it needs more containers.
  2. Step 2: Apply min and max capacity limits

    Min is 2, max is 5. Scaling up is allowed up to 5 containers to reduce CPU load.
  3. Final Answer:

    The service scales up to 5 containers to reduce CPU load -> Option A
  4. Quick Check:

    CPU above target scales up containers = The service scales up to 5 containers to reduce CPU load [OK]
Hint: CPU above target scales up, below scales down [OK]
Common Mistakes:
  • Thinking service scales down when CPU is high
  • Ignoring max capacity limit
  • Assuming service crashes on high CPU
4. You configured ECS service auto scaling but the service never scales out even when CPU is high. What is a likely cause?
medium
A. The service has no load balancer attached
B. The target CPU utilization is set to 100%
C. The ECS cluster has no running tasks
D. The maximum capacity is set equal to the minimum capacity

Solution

  1. Step 1: Analyze scaling limits

    If max capacity equals min capacity, no room to scale out exists.
  2. Step 2: Check other options

    Target 100% means scaling triggers only at max CPU, but scaling can still happen. No running tasks or load balancer affect service but not scaling limits directly.
  3. Final Answer:

    The maximum capacity is set equal to the minimum capacity -> Option D
  4. Quick Check:

    Max equals min blocks scaling out = The maximum capacity is set equal to the minimum capacity [OK]
Hint: Max capacity must be greater than min capacity to scale out [OK]
Common Mistakes:
  • Ignoring max and min capacity settings
  • Assuming load balancer affects scaling triggers
  • Confusing target CPU with scaling limits
5. You want to configure ECS service auto scaling to keep container count between 3 and 10, scaling based on memory usage targeting 70%. Which configuration is correct?
hard
A. MinCapacity: 10, MaxCapacity: 3, TargetValue: 70, PredefinedMetricType: ECSServiceAverageMemoryUtilization
B. MinCapacity: 3, MaxCapacity: 10, TargetValue: 70, PredefinedMetricType: ECSServiceAverageMemoryUtilization
C. MinCapacity: 3, MaxCapacity: 10, TargetValue: 70, PredefinedMetricType: ECSServiceAverageCPUUtilization
D. MinCapacity: 3, MaxCapacity: 10, TargetValue: 30, PredefinedMetricType: ECSServiceAverageMemoryUtilization

Solution

  1. Step 1: Set correct min and max container counts

    MinCapacity must be less than MaxCapacity, so 3 and 10 is valid, 10 and 3 is invalid.
  2. Step 2: Use correct metric and target value for memory

    Memory scaling uses ECSServiceAverageMemoryUtilization with target 70% to trigger scaling.
  3. Step 3: Verify options

    MinCapacity: 3, MaxCapacity: 10, TargetValue: 70, PredefinedMetricType: ECSServiceAverageMemoryUtilization matches all requirements: correct min/max, target 70, memory metric.
  4. Final Answer:

    MinCapacity: 3, MaxCapacity: 10, TargetValue: 70, PredefinedMetricType: ECSServiceAverageMemoryUtilization -> Option B
  5. Quick Check:

    Correct min/max and memory target = MinCapacity: 3, MaxCapacity: 10, TargetValue: 70, PredefinedMetricType: ECSServiceAverageMemoryUtilization [OK]
Hint: Min < Max and match metric to resource (memory or CPU) [OK]
Common Mistakes:
  • Setting max less than min capacity
  • Using CPU metric for memory scaling
  • Setting wrong target value for scaling
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard