Amazon Elastic Container Service (ECS) is used for running Docker containers on AWS.
Docker is a technology that provides the tools for you to build, run, test, and deploy distributed applications that are based on Linux containers.
Amazon ECS uses Docker images in task definitions to launch containers as part of tasks in your clusters.
Amazon ECS has two launch types:
- ECS with Amazon EC2 – you manage the underlying EC2 instances on which tasks (containers) run.
- AWS using AWS Fargate – fully serverless service for running tasks.
Spot instance draining:
- Spot Instance Draining reduces service interruptions due to Spot termination for ECS workloads.
- This feature enables ECS customers to safely manage any interruptions of ECS tasks running on Spot instances due to termination of the underlying EC2 Spot instance.
- Automated Spot Instance Draining will automatically place Spot instances in “DRAINING” state upon the receipt of two minute interruption notice.
- ECS tasks running on Spot instances will automatically be triggered for shutdown before the instance terminates and replacement tasks will be scheduled elsewhere on the cluster.
Service Auto Scaling (ECS + Fargate)
Automatic scaling is the ability to increase or decrease the desired count of tasks in your Amazon ECS service automatically. Amazon ECS leverages the Application Auto Scaling service to provide this functionality.
Amazon ECS publishes CloudWatch metrics with your service’s average CPU and memory usage.
You can use these and other CloudWatch metrics to scale out your service (add more tasks) to deal with high demand at peak times, and to scale in your service (run fewer tasks) to reduce costs during periods of low utilization.
Amazon ECS Service Auto Scaling supports the following types of automatic scaling:
- Target Tracking Scaling Policies—Increase or decrease the number of tasks that your service runs based on a target value for a specific metric. This is similar to the way that your thermostat maintains the temperature of your home. You select temperature and the thermostat does the rest.
- Step Scaling Policies—Increase or decrease the number of tasks that your service runs based on a set of scaling adjustments, known as step adjustments, that vary based on the size of the alarm breach.
- Scheduled Scaling—Increase or decrease the number of tasks that your service runs based on the date and time.
Cluster Auto Scaling (ECS)
Amazon ECS cluster auto scaling enables you to have more control over how you scale the Amazon EC2 instances within a cluster.
Automatically adds and removes cluster instances using Auto Scaling.
When creating an Auto Scaling group capacity provider with managed scaling enabled, Amazon ECS manages the scale-in and scale-out actions of the Auto Scaling group used when creating the capacity provider.
Fargate is a serverless compute engine for running Docker containers.
Works with both Amazon ECS and Amazon EKS.
You don’t provision or manage any servers.
You pay for resources per application.
Fargate automatically allocates the right amount of compute.
No over-provisioning or paying for additional servers.
Fargate runs each task (ECS) or pod (EKS) in its own kernel providing an isolated compute environment.
Can use Spot and Compute Savings Plan pricing options.
Error: CannotPullContainerError: API error (500): Get https://111122223333.dkr.ecr.us-east-1.amazonaws.com/v2/: net/http: request canceled while waiting for connection”
To resolve the above error, you can:
- For tasks in public subnets, specify ENABLED for Auto-assign public IP when launching the task.
- For tasks in private subnets, specify DISABLED for Auto-assign public IP when launching the task, and configure a NAT gateway in your VPC to route requests to the internet.
Amazon Elastic Container Registry (ECR) is a fully managed container registry.
Used for storing container (Docker) images.
Can store, manage, share and deploy container images.
Highly available and high-performance.
Works with Amazon ECS, EKS, and AWS Lambda.
Resource-level control for each repository through integration with AWS Lambda.
Pay for what you store.