ECS service is configured to have desired count = 1 as part of initial setup. Auto-scaling with policy type = "TargetTrackingScaling" and PredefinedMetricType = "ECSServiceAverageMemoryUtilization" is set with target value 75%, i.e. it should auto scale if average memory used by service is above or below 75%.
Auto scale target is configured with Max capacity = 5, Min capacity = 1 (target = ECS service in this case)
After application started, Memory utilization increased above 75% as more and more requests hit the tasks which triggered cloudwatch scale-out alarm and a new task is successfully added to the service.
Once all the requests were processed, memory utilization came down to ~58% which triggered a scale-in cloudwatch alarm but a task was not removed from the ecs service. The two running tasks have memory utilized ~3165MB and ~1454MB and max memory configured for tasks is 4096. Can anyone tell why a task was not removed ?