Search code examples
amazon-ecs

AWS-ECS - restart service immediately


I am trying to restart my ECS service. Whenever I issue the below command, it takes 5 minutes for the ECS to re-start service.

aws ecs update-service --service name --force-new-deployment

Note that I mean, ECS does that only after 5 mins. 5 mins wait time seems to be 'draining' phase. However my application does not even process a single request. So why is it waiting for 5 minutes?

How can I forcefully restart immediately via commandline?


Solution

  • The command aws ecs update-service --service name --force-new-deployment execute a simple process:

    • Start a new task, when the health check marks as healthy the service begins to drain the old task and starts the load balancer to divert the connections towards the new task. For this reason it takes some minutes.

    If you want to stop immediately you need to use aws ecs stop-task Check here about it and then start the new task, use aws ecs start-task Check here about it or run-task Check here about it. But you will have a downtime.