Amazon ECS: Elastic Container Service
Containers are a way of OS virtualization building block that let you run an app and its dependencies in resource-isolated processes. Containers allow to easily package an application’s code, configurations, and dependencies into building blocks that bring operational efficiency, consistency, productivity, and version control. Containers can help in ensuring applications quick deployment, reliability, and consistency regardless of deployment or any environment. Containers provide more granulated control over resources which gives infrastructure improved efficiency. Running containers in the AWS Cloud environment allows to build strong, scalable applications and services by using the AWS Cloud benefits such as availability, elasticity, security by using the pay-as-you-grow method (only pay for the resources being used/consumed).
Amazon EC2 Container Service (ECS) is a cloud computing service in Amazon Web Services (AWS) that manages and controls containers. It allows developers to manage and deploy highly scalable apps that can run on clusters (groups of servers) via APIs. By the help of simple API calls, Docker-enabled applications can be started and stopped, queried the complete state of your app, and can be accessed many familiar features such as IAM roles, security groups, load balancers, Amazon CloudWatch Events, AWS CloudFormation templates, and AWS CloudTrail logs.
Amazon has developed ECS in response to the acceptance of containerization. ECS allows a developer to stipulate rules for isolated sets of Elastic Compute Cloud (EC2) instances to increase portability and computing performance by running on top of a host OS. ECS supports Docker, an open source Linux container service.
ECS Basic Concepts
Before we dig deep further, let’s get aware with some ECS concepts and terminologies.
Cluster: A logical group of EC2 container instances where you build, shape, and operate different workloads.
Container instance: Container instance is an EC2 instance that actually runs on the ECS agent. ECS agent is also open source.
Container agent: Container agent is the agent that actually runs on EC2 instances that helps to form the ECS cluster and if ECS optimized AMI is used, it automatically installed with the agent. But if you run your own OS or AMI, then you need to install the agent manually. The container agent is also an open source and can be found here:
Task definition: Is an application contains one or more containers which requires Docker images, the amount of CPU/Memory to use, ports etc. we can simply link containers here as similar to a Docker command line.
Task: An instance of a task that runs on a container instance.
Service: A service that allows to run and maintain specified instance(s) of a task definition. If a task in a service stops, the task is restarted.
Container: A Docker container that executes as a part of a task definition.
Amazon ECS Features
Running Containers Without Servers
Amazon ECS features AWS Fargate, where containers can be managed and deployed without having to provision or manage servers. By using AWS Fargate, you no need to select Amazon EC2 instance types, provisioning, and scaling clusters of VMs to run or schedule containers to maintain their availability. Fargate allows to focus on constructing and executing applications, rather than underlying infrastructure.
Everything is Containerized
Amazon ECS allows us to build any type of containerized application very easily from running apps and micro-services to batch jobs and machine learning apps. We can easily move legacy Linux or Windows apps from on-premises to cloud infrastructure and execute them as containerized apps by using Amazon ECS.
Robust and Secure
Amazon ECS launches the containers inside your own Amazon VPC and allows to use your VPC security groups and network ACLs without sharing compute resources to other customers. You can restrict access and permissions to your containers using IAM to each service and resources that a container can access. This high level of isolation helps us in building highly secure and reliable apps using Amazon ECS.
Performance at a High Scale
Amazon ECS is a technology where you can launch thousands of Docker containers in seconds using Amazon ECS without additional complexity involved.
Compatible with Other AWS Services
Amazon ECS is easily integrated with AWS IAM, AWS CloudFormation, Amazon VPC, Elastic Load Balancing, Amazon CloudWatch, AWS Batch, AWS CodeStar, Amazon ECR, and AWS CloudTrail services which provide a complete solution for running and executing a broad range of containerized apps or services:
Amazon ECS Use Cases
Following are some cases where we can use Amazon ECS:
Amazon ECS supports to run microservices apps with native integration and incorporation to AWS services and allows continuous integration and continuous deployment (CICD) pipelines.
App Migration to Cloud
With the help of Amazon ECS, enterprise apps can be containerized and easily moved to AWS cloud without requiring any code variations.
Amazon ECS allows to run batch processes and workloads with managed/custom schedulers on Amazon EC2 On-Demand Instances, Reserved Instances, or Spot Instances.
Amazon ECS helps to containerize Machine Learning models for both training and inference purposes. With Amazon ECS, you can create Machine Learning models made up of loosely coupled and distributed services that can be positioned on any platform.
Amazon Elastic Container Service Pricing
Following are two different cost models for Amazon Elastic Container Service (ECS).
With Fargate launch type model, you only pay for the vCPU and memory resources that your containerized app uses. A minimum charge of 1 minute is applied as both vCPU and memory resources are calculated from the time where your container images are pulled until the Amazon ECS Task terminates, rounded up to the nearest second.
You can follow detailed pricing information on the AWS Fargate pricing page.
In EC2 launch type mode, you pay for the use of AWS resources (e.g. EC2 instances or EBS volumes) which are created to store and run your app. You only have to pay for what you use, as you use it and there are no minimum fees and no upfront commitments required.
You can follow detailed pricing information on the Amazon EC2 pricing page.