Skip to content

ECS Service auto scaling policy conflict the one to other policy

0

Hi, i have an ECS servcie that have an auto scaling policy. it is step scaling policy like when cpu utilization goes above 50% then add 1 task and it goes below 30% its remove that added task. then also i have a policy for memory utilization goes above 50% add 1 task and also remove task for memory utilization goes below 30%

my problem is when cpu usage is going to above 50% like 55% usage then auto scaling perform to add one task but memory utilization is below 30% so that scale in policy of memory utilization 30% policy remove that task added from cpu above 50% usage scale out policy

please help me out above senario which action i take to solve

3 Answers
2

To keep it simple I suggest you use Target tracking scaling policy for the ECSServiceAverageMemoryUtilization metric and tick the Turn off scale-in checkbox. So you rely only on CPU utilization as a criteria for scaling in.

AWS
EXPERT
answered 2 years ago
  • There's no need to disable scale-in on the 2nd policy. Target tracking will only scale in when BOTH policies want to scale-in at the same time. So leaving it enabled on both will prevent oscillation

2

This is the exact situation where you should use Target Tracking.

Create 2 Target Tracking policies, one for CPU, and one for Memory.

When there are multiple target tracking policies, any policy being above the threshold can trigger scale-out; but scale-in only happens when all policies want to scale-in at the same time. This prevents the oscillation you're describing, since scale-in only happens when both Memory and CPU are low at the same time

AWS
EXPERT
answered 2 years ago
0

Hello,

The Issue: Your ECS service has two conflicting auto scaling policies:

  1. CPU Scaling Policy (Scale Out): Adds a task when CPU utilization exceeds 50%.
  2. Memory Scaling Policy (Scale In): Removes a task when memory utilization falls below 30%.

These policies can lead to unnecessary scaling activity, where a task added due to high CPU might be immediately removed due to low memory.

Here are two approaches to address this:

Prioritize Scaling Policies:

Define a priority order for the policies. The policy with higher priority will take precedence. In this case, set CPU scaling to a higher priority than memory scaling. This ensures scaling based on CPU first, and memory scaling won't remove a task immediately after CPU scaling adds one.

Steps:

  • Go to the ECS service in the AWS Management Console.
  • Navigate to the "Auto Scaling" section.
  • Click on the "Edit" button for each policy.
  • Set a higher priority value (lower number) for the CPU scaling policy.

Combine Scaling Metrics:

Create a single policy that considers both CPU and memory utilization. This policy can add or remove tasks based on a combined threshold that factors in both metrics.

Steps:

  • Go to the ECS service in the AWS Management Console.
  • Navigate to the "Auto Scaling" section.
  • Click on "Create a new policy."
  • Choose "Target Tracking Scaling" policy type.
  • Define a target for combined CPU and memory utilization (e.g., average CPU above 40% and memory above 40%).
  • Set scaling actions (add/remove tasks) based on deviations from the target.

ECS Auto Scaling doc: https://docs.aws.amazon.com/AmazonECS/latest/developerguide/service-auto-scaling.html.

EXPERT
answered 2 years ago
EXPERT
reviewed 2 years ago
EXPERT
reviewed 2 years ago
EXPERT
reviewed 2 years ago
  • very thankyou for imediate response.

    i appriciate your answer but i not find anything like Prioritize Scaling Policies in ECS service auto scaling.

    and also target tracking scaling policy not support to select multiple metrics and also no selection for any exsisting alarm.

    again thank you for your response please let me know any other option to solve my issue

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.