Back to results for “Elastic Load Balancing (ALB”
AWS › Amazon ECS (Elastic Container Service)

How does an ECS service maintain the desired number of running tasks?

Intermediate

Answer

An ECS service continuously monitors the number of running tasks against a desired count you specify, automatically launching replacement tasks if any fail or are stopped unexpectedly, and it can also integrate with an Application Load Balancer to distribute incoming traffic evenly across all healthy running tasks.
aws ecs update-service --cluster my-cluster --service my-service --desired-count 4
Real-world example An e commerce application configures its ECS service to always maintain four running tasks, so if one container crashes due to an unexpected error, ECS automatically starts a replacement without any manual intervention.

Common follow-ups: How does ECS decide which unhealthy task to replace first?;What is the relationship between an ECS service and a load balancer target group?