What is AWS ECS?


AWS Elastic Container Service is a highly scalable, fast container management service. It makes it easy to run, stop and manage containers on a cluster.

So what does all of this actually mean? 

What AWS ECS does is help a user in running containers, it also makes it easy to run them in a cluster and manage those clusters. Containers are defined in a task definition which is used to perform a task. Tasks can be an individual entity or can be part of a service as well. A service in the context of ECS is running and maintaining a certain number of tasks at a time.

But what is a container?

A container is a standardised unit of software development that contains everything your application needs to run, including relevant code, runtime, system tools and dependencies which the code has. 

These containers are created from a read-only template called an image.

Now, let’s leave all that jargon behind and understand what all of that means in simple terms. 

Let us imagine a shipping container, one of the biggest advantages is that it can carry anything and it keeps whatever it carries isolated from the environment outside of the container. While on a ship, one container might contain tyres but in the containers right next to it there can be a bunch of TVs. What is inside does not affect anything around it. 

The same way, a container is an isolated environment where application code is run, it contains everything that application code needs to run successfully, whenever an application needs to scale up or down another container can be started or stopped respectively, this gives applications immense modularity. 

The configuration of what runs inside a container is defined by an image which is a read only file. An image defines the base OS which runs inside the container, the commands which need to run in the container once it starts up and all the system tools which need to be installed before the application code is launched. It also defines ports through which the container can communicate with the rest of the network.

So how can we launch these containers?

Containers are launched in 2 ways, they are known as launch types in AWS.

Launch Types

When we talk about tasks and running multiple tasks at once, we immediately think of the computing needs and how we manage the computing infrastructure. With ECS there are 2 ways of managing scalability aka Launch Type : 

  • AWS Fargate: AWS Fargate is a serverless infrastructure on which our tasks run and the scalability of the cluster and its computing needs are handled automatically. 
  • Amazon EC2 Launch Type: For more control over your infrastructure you can choose to use the EC2 launch type, which lets you run containers on EC2 instances which are managed by you. This is a cheaper option as compared to the Fargate launch type.

High Level Architecture of an ECS Cluster

 ECS can run and manage containers running in a single region but across multiple AZs. These clusters can run within an existing VPC or if needed they can create a new VPC of their own automatically. All you have to do is select a check box which will then create a VPC for your cluster to be deployed in. 

As seen in the above image, containers run according to a task, which run according to a task definition. 

Task definition is a text file in the JSON format, it’s like a blueprint of your application which defines the amount of containers (up to 10) that form your application. It also defines which containers to be used, which ports to be exposed etc. The parameters for any task definition are task specific. 

Once a task definition is complete, each instance of the task definition is known as a task

The AWS ECS - Task Scheduler is responsible for placing tasks within your cluster. Each task can be a part of a service, and a service manages the tasks, you can define multiple services with the same tasks, with each service instructed to manage the tasks in different ways. You can specify the number of tasks to be run on your cluster at a time or specify a limit on them. 

The entity under which all services or tasks run is a cluster, you can register one or more EC2 instances with your cluster to use the EC2 instance launch type. These EC2 instances are also known as container instances.

When we talk about launch types and scaling of tasks, we also need to talk about how the service knows which task needs to be scaled, for this there is something known as a Container agent which is present inside every container in an ECS cluster. Container agent manages processes on a container level. It sends the cluster information regarding the container such as the compute resources occupied and which processes are being run on a container. Based on the resource utilisation information provided by the container agent, ECS manages the cluster.

The last piece of the puzzle is the cluster, cluster is the entity under which a single or more services run in sync according to their own configurations, a cluster manages the services in a single region across multiple availability zones. It also provides an easy way of managing and maintaining a service.


I hope the explanation present in this blog was enough for your understanding, I will be diving deeper into AWS ECS and its features in future blogs.