Application Load balancer with ECS

0

Hello, I have my dockerize app and I deployed that with ECS. Now I have one doubt, I choose the number of instances two, and the number of tasks also two, and it works well. My question is If I terminate one instance then in the target group, two tasks work on a single instance and after a couple of minutes new instance is automatically created but in the target group both task uses that first instance only. And in this case, the second instance is created successfully but ALB not using the second instance. Can someone guide me? Thanks

1개 답변
2
수락된 답변

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
전문가
Peter_G
답변함 일 년 전
  • Does it mean, till any of the failures the second EC2 instance will be running idle?

  • till any failure or if autoscaling tells ecs to scale up more than 2. EG you could change the desired count to 3 and then back down to 2 for a rebalance

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠