JeffJassky
JeffJassky

Reputation: 91

How to keep AWS ECS from shutting down during a critical moment?

Is there a way to ensure an AWS ECS container instance doesn't shut down in the middle of running a critical task?

I have an auto-scaling AWS ECS service that scales the number of instances based on CPU usage. These instances process long-running batch jobs that may take anywhere from 5 to 30 minutes.

The problem is that sometimes, during a scale-down, an instance that's actively running a critical job gets shut down which ultimately causes the job to fail.

Upvotes: 2

Views: 1734

Answers (1)

Dennis Traub
Dennis Traub

Reputation: 51674

You can use a feature called managed termination protection.

When the scaling policy reduces the number of instances, it has no control over which instances actually terminate. The default behavior of the auto-scaling group may well terminate instances that are running tasks, even though there are instances not running tasks. This is where managed termination protection comes into the picture. With this option enabled, ECS dynamically manage instance termination protection on your behalf.

Please have a look at Controlling which Auto Scaling instances terminate during scale in and specifically the section Instance scale-in protection in the AWS documentation.

Upvotes: 2

Related Questions