Graceful ECS Service Rotation in Traefik to Avoid 503s

Hello Everyone,

I would greatly appreciate any assistance with an issue I've been unable to resolve despite extensive online research. I'm looking for guidance and hoping someone here can point me in the right direction.

My current AWS setup includes:

  • Route53 for DNS
  • ALB for SSL Termination
  • Traefik, positioned after ALB in a target group
  • Containers running on ECS (Using EC2), utilizing Traefik's ECS provider and Docker labels in the task definition

The issue I'm facing arises during the deployment of our ECS services. New services get registered in Traefik, but there's a brief period when the old ECS services, which are being terminated, continue to receive traffic from Traefik. This results in 503 errors.

My question is: Is there a way or a specific deployment configuration in Traefik with ECS that could prevent Traefik from routing traffic breifly to terminated ECS services that causing these errors? Ideally, I'm looking for a solution that would allow for a graceful rotation of the old services out of Traefik load balancer before they are terminated by ECS during deployment.

Any insights or suggestions would be highly appreciated!