When using ECS with EC2 tasks do not re-balance automatically after a failure event unless autoscaling tells it to for some other reason (eg responding to performance). Check out this sample code which uses Cloudwatch events to modify a service back to 1 desired count and then back to 2 to respread the tasks.
You might also want to consider using fargate instead of EC2. You can configure fargate to use all the possible AZ's in a region (usually 3) so if one task fails due to an AZ issue it will be restarted in a different AZ to the other task within the service by default
- AWS OFFICIALUpdated 3 years ago
- How do I troubleshoot Application Load Balancer health check failures for Amazon ECS tasks on Fargate?AWS OFFICIALUpdated 10 months ago
- AWS OFFICIALUpdated 2 years ago
- EXPERTpublished 9 months ago
- EXPERTpublished 4 months ago