BACKGROUND IMAGE: iSTOCK/GETTY IMAGES
Amazon Elastic Container Service (ECS) is a cloud computing service in Amazon Web Services (AWS) that manages containers and allows developers to run applications in the cloud without having to configure an environment for the code to run in. It enables developers with AWS accounts to deploy and manage scalable applications that run on groups of servers -- called clusters -- through application program interface (API) calls and task definitions. Amazon ECS is a scalable service that is accessible through the AWS Management Console and software development kits (SDKs).
Amazon developed ECS in response to the rise in popularity of containerization. ECS enables a developer to specify rules for isolated sets of EC2 instances which increase portability and computing performance by running on top of a host operating system (OS). ECS supports Docker, an open source Linux container service.
Amazon ECS enables developers to easily use Docker containers for a range of activities; from hosting a simple website to running complex, distributed microservices that require thousands of containers. ECS evaluates and monitors CPU and memory output to determine the optimal deployment for a container. AWS customers can also use the service to update containers or scale them up or down. AWS Elastic Load Balancing (AWS ELB), Elastic Block Store (AWS EBS) volumes and Identity and Access Management (AWS IAM) roles are also supported for further customization.
Uses of Amazon Elastic Container Service
Amazon ECS is best used with:
- Machine learning - Machine learning (ML) models can be easily containerized for training and inference with Amazon ECS. ML models can be created with loosely coupled, distributed services that can be placed on a variety of platforms or close to the data that's being analyzed by the application.
- Microservices - Amazon ECS assists in the operation of microservices applications by providing native integration to AWS and enabling continuous integration and continuous deployment (CI/CD) pipelines.
- Virtual machines - The Amazon Elastic Compute Cloud (Amazon EC2) web service can be used to create and operate Linux virtual machines (VMs) in the cloud; these VMs are called instances. Developers can specify rules for the isolated sets of EC2 instances which increase computing performance and portability by running on top of a host operating system.
- Migrating apps to the cloud - Legacy enterprise applications can be feasibly containerized and migrated to Amazon ECS without necessitating any code changes.
- Batch processing - Batch workloads can be run with custom or managed schedulers on AWS On-Demand Instances, Reserved Instances or Spot Instances.
How Amazon Elastic Container Service works
AWS account holders can integrate the ECS service with other Amazon Web Services, such as:
- AWS CloudTrail logs
- AWS Command Line Interface (AWS CLI)
- Amazon Elastic Compute Cloud (EC2)
- AWS CloudFormation templates
- AWS SDKs
- AWS Tools for Windows PowerShell
- Amazon Elastic Container Registry (Amazon ECR)
Amazon ECS allows developers to define their application by pulling the necessary Docker images and resources from Amazon ECR or other repositories. Once all the appropriate containers have been gathered, they are deployed, either on EC2 or AWS Fargate. Finally, Amazon ECS scales the application and continuously manages the availability of containers.
Amazon Elastic Container Service features
Scheduling - Schedulers place containers over clusters according to the desired resources -- such as RAM or CPU -- and availability requirements. This feature can be used to schedule batch jobs and long-running applications or services.
Amazon ECS includes two schedulers which enable users to deploy containers based on computing needs or availability requirements. AWS Blox, an open source container orchestration tool, integrates with ECS to schedule containers. Long-running applications and batch jobs benefit from the use of schedulers for their responsiveness; ECS also supports third-party scheduling options.
Docker integration - Docker is supported by Amazon ECS, thus allowing AWS users to manage Docker containers across clusters of Amazon EC2 instances. Each EC2 instance in a cluster runs a Docker daemon that deploys and runs any application packaged as a container locally on Amazon ECS without the need to make any changes to the container.
Networking - Amazon ECS supports Docker networking as well as integration with Amazon Virtual Private Cloud (Amazon VPC) to provide isolation for containers, thus providing developers with control over how the containers interact with other services and external traffic. Four networking modes are available for the containers; each one supports different use cases. The modes include:
- Host mode - Adds containers directly to the host's network stack and exposes containers on the network that are not isolated.
- Task networking mode - Assigns every running Amazon ECS task a dedicated elastic networking interface which provides the containers with full networking features in Amazon VPC, similar to EC2 instances.
- None mode - Deactivates external networking for containers.
- Bridge mode - Creates a Linux bridge that is used to connect all containers operating on the host in a local virtual network that is accessed through the host's default network connection.
Cluster management - Amazon ECS handles all of the cluster management processes for the developer. This typically involves installing, operating and scaling cluster management software, monitoring solutions and configuration management systems as well as building the architecture and managing the availability and scalability of each system. With Amazon ECS, the developer simply launches a cluster of container instances and specifies the desired tasks to perform.
Task Definitions - Tasks can be defined through a declarative JSON template called a Task Definition. The Task Definition allows developers to specify which containers they need for their task, including memory and CPU requirements, Docker repository and images, shared data volumes, as well as choose how the containers are connected to each other. Task Definition files also allow developers to version control their application specification.
Load balancing - Integration with the AWS ELB allows developers to distribute traffic across containers. They can specify the Task Definition and ELB to use, and then the Amazon ECS scheduler automatically adds and removes containers using the ELB.
Repository support - Any third party repository, accessible private Docker registry or Docker Hub can be used with Amazon ECS as long as it is specified in the Task Definition.
Local development - The AWS CLI allows users to simplify the local development experience and easily set up an Amazon ECS cluster and it related resources. The CLI also supports Docker Compose which is an open source tool used to define and run multi-container applications.
Programmatic control - Various simple APIs are offered that allow developers to integrate and extend the Amazon ECS service. The APIs enable users to create or delete clusters, launch or destroy Docker containers and register or unregister tasks as well as access detailed information about the state of the cluster and its instances. AWS CloudFormation can also be used to deliver Amazon ECS clusters, register Task Definitions and schedule containers.
Logging - Issue diagnosis can be made simpler by sending every container instance's ECS agent logs and Docker container logs to Amazon CloudWatch logs. All Amazon ECS API calls can also be recorded and the log files will be delivered to the user through AWS CloudTrail.
Monitoring - Monitoring capabilities are provided for the containers and clusters. Average and aggregate CPU can be supervised as well as the memory utilization of running tasks grouped by Task Definition, service or cluster through Amazon CloudWatch. Furthermore, CloudWatch alarms can be set to alert developers whenever a container or cluster needs to be scaled up or down.
Container deployments - Containers can be easily updated to the newest versions. Whenever a new version of the application Task Definition is uploaded, the Amazon ECS scheduler automatically starts new containers using the updated image and disables any container running on the old version. Amazon ECS will also register and unregister the appropriate new and old containers from the AWS ELB.
Container auto-recovery - Unhealthy containers are automatically recovered by the Amazon ECS service scheduler. This ensures the necessary number of containers are constantly supporting the application.
Amazon ECS runs containers on top of EC2 instances which provides isolation to help businesses achieve compliance. EC2 instances reside in the Amazon VPC and a user can specify which instances are exposed to the internet.
EC2 instances and ECS tasks also adhere to IAM roles, while security groups and network access control lists limit access to instances. An administrator can also provision EC2 Dedicated Instances for containers to provide extra workload isolation.
Administrators can adjust security settings at the OS level and implement other monitoring or management tools to protect ECS containers.
Benefits of Amazon Elastic Container Service
Amazon ECS is a beneficial choice for modern software teams that are smaller and cross-functional because it is simple and fast to set up to start running. Furthermore, since it is a fully managed platform from Amazon Web Services, users do not have to worry about dealing with platform-related issues, and can instead focus on migrating their app.
Other benefits include:
- Improved security - Amazon ECR and ECS collaborate to provide optimal application security.
- Cost efficient - Amazon ECS allows developers to schedule various containers on the same node , thus achieving high density on Amazon EC2.
- Performance at scale - Thousands of Docker containers can be launched in seconds without any additional complexity using Amazon ECS. This is because the service is built on technology that has been developed from years of experiences running highly scalable services.
- Improved compatibility - The container-based pipeline helps eliminate any issues that may arise due to deployments functioning differently in various environments.
- Designed for collaboration with other AWS services - Integration of Amazon ECS with other AWS services, such as Amazon ECR and AWS ELB, provides users with a complete solution for running a variety of containerized applications and services.
- Manageable at any scale - Operating cluster management software and creating fault-tolerant clusters is unnecessary when using Amazon ECS. Since there is no software to install, scale and manage, developers can focus on building their container-based applications.
- Extensible - Amazon ECS offers total visibility and control of the AWS resources, thus allowing it to be easily integrated or extended through APIs.
Amazon Elastic Container Service vs. Kubernetes
Amazon ECS competes with Kubernetes, Google's open source container orchestration system. While the container management tools and use cases differ, Kubernetes has the following features that ECS does not:
- it is deployable to non-AWS clouds and on-premises resources;
- it has storage options outside AWS; and
- it receives contributions from the developer community, while not all ECS code is publicly available.
But Amazon ECS might be a simpler option for businesses that rely on AWS exclusively, or that want a container management platform with easy installation. Load balancer tools, resource monitoring, auto scaling and service management features are comparable between the two options.
Amazon Elastic Container Service pricing
There is no additional cost to AWS customers for using ECS, though users still pay for EC2 instances and EBS volumes in the cluster, plus any other billable AWS resources used.