Posted On: Jan 21, 2024

Today, Amazon Elastic Container Service (Amazon ECS) announced managed instance draining, a new capability that facilitates graceful shutdown of workloads deployed using Amazon ECS on Amazon Elastic Compute Cloud (Amazon EC2) instances by safely stopping and rescheduling workloads to other, non-terminating instances. This capability enables customers to simplify infrastructure maintenance workflows, such as rolling out a new Amazon Machine Image (AMI) version, without needing to build custom solutions to gracefully shutdown instances without disrupting their workloads.

Amazon ECS customers can deploy their workloads on serverless compute with Amazon Fargate or on Amazon EC2 instances for greater control over infrastructure provisioning. With Fargate, customers can just focus on building and deploying their workloads, however, deploying workloads on Amazon EC2 requires customers to manage infrastructure operations, such as scaling capacity, performing OS and security updates, configuring instance mix, and monitoring instance health. Amazon ECS Capacity Providers manage automatic scaling of Amazon EC2 instances in response to workload requirements by leveraging Auto Scaling groups (ASG). With today’s launch, capacity providers facilitate graceful termination of Amazon EC2 instances by safely stopping running tasks, launching replacement tasks on other non-terminating instances, and delaying instance termination until all tasks have stopped gracefully (up to 48 hours). Customers can now simplify infrastructure updates using ASG features, such as instance refresh to roll out a new AMI version, or maximum instance lifetime for periodic instance replacement, or any custom implementation without needing to build a solution to gracefully shutdown instances without disrupting their workloads.

This capability is now available in Amazon Web Services China (Beijing) Region, operated by Sinnet and Amazon Web Services China (Ningxia) Region, operated by NWCD. To get started, see the following resources:

Managed Instance Draining in the Amazon ECS User Guide
Instance refresh in the Amazon EC2 Auto Scaling user guide
Maximum instance lifetime in the Amazon EC2 Auto Scaling user guide