Browse the Repo

file-type-icon.circleci
file-type-icon_docs
file-type-iconexamples
file-type-iconmodules
file-type-icontest
file-type-icon.gitignore
file-type-icon.pre-commit-config.yaml
file-type-iconCODEOWNERS
file-type-iconLICENSE.txt
file-type-iconREADME.adoc
file-type-iconcore-concepts.md
file-type-iconsetup.cfg
file-type-iconterraform-cloud-enterprise-private-module-...

Browse the Repo

file-type-icon.circleci
file-type-icon_docs
file-type-iconexamples
file-type-iconmodules
file-type-icontest
file-type-icon.gitignore
file-type-icon.pre-commit-config.yaml
file-type-iconCODEOWNERS
file-type-iconLICENSE.txt
file-type-iconREADME.adoc
file-type-iconcore-concepts.md
file-type-iconsetup.cfg
file-type-iconterraform-cloud-enterprise-private-module-...
EC2 Container Service (ECS) Cluster

EC2 Container Service (ECS) Cluster

Deploy a cluster of servers for use with EC2 Container Service (ECS), Amazon's container orchestration system

Code Preview

Preview the Code

mobile file icon

core-concepts.md

down

Core ECS Concepts

What is Elastic Container Service?

Elastic Container Service (ECS) is the official AWS solution for running Docker containers on a cluster of servers in a fault-tolerant, scalable, and highly available way. Its primary advantage over alternatives like Mesos and Kubernetes is that it's much easier to set up, understand, and integrate with other AWS services. Its primary downside is that it offers less powerful options for "scheduling" containers across different hosts.

Helpful Vocabulary

Amazon has its own vocabulary for ECS that can be confusing. Here's a helpful guide:

  • ECS Cluster: One or more servers (i.e. EC2 instances) that ECS can use for deploying Docker containers.
  • Container Instance: A single node (i.e. EC2 Instance) in an ECS Cluster.
  • ECS Task: One or more Docker containers that should be run as a group on a single instance.
  • ECS Task Definition (AKA ECS Container Definition): A JSON file that defines an ECS Task, including the container(s) to run, the resources (memory, CPU) those containers need, the volumes to mount, the environment variables to set, and so on.
  • Task Definition Revision: ECS Tasks are immutable. Once you define a Task Definition, you can never change it: you can only create new Task Definitions, which are known as revisions. The most common revision is to change what version of a Docker container to deploy.
  • ECS Service: A way to deploy and manage long-running ECS Tasks, such as a web service. The service can deploy your Tasks across one or more instances in the ECS Cluster, restart any failed Tasks, and route traffic across your Tasks using an optional Elastic Load Balancer.

Cluster hosting options

ECS supports hosting your docker services using either ECS container instances or Fargate.

What are ECS Container Instances?

ECS container instances are EC2 instances associated with an ECS cluster. These instances register with the cluster to allow scheduling of Docker containers managed by ECS. This gives you control over the hosting platform used for running your Docker containers so that you can choose how much compute or dedicated hardware to provide to your containers.

What is Fargate?

Fargate is a technology for Amazon ECS that allows you to run containers without having to manage servers or clusters. With AWS Fargate, you no longer have to provision, configure, and scale clusters of virtual machines to run containers. This removes the need to choose server types, decide when to scale your clusters, or optimize cluster packing.

EC2 vs Fargate launch types

EC2 launch type Functionality

  • You have full control over the servers and how they are configured.
  • You deploy, maintain, patch, monitor, and scale the servers yourself.
  • You can control costs with spot instances and reserved instances.
  • You can use Docker images in private registeries.
  • You have to manually monitor the EC2 instances in your cluster.
  • Supports Classic Load Balancers, Application Load Balancers and Network Load Balancers

Fargate Functionality

  • You hand AWS a container and it figures out how to deploy it. You don't have to worry about the servers at all, just your app/containers.
  • Fargate could be slightly more expensive than ECS because of the lack of fine grained control over the instance sizes. Detailed pricing breakdown here
  • Fargate starts up containers slightly slower because of the overhead of newly creating the underlying infrastructure.
  • Fargate doesn't support all Task Definition parameters, more info here
  • Fargate only supports images in Amazon ECR or public repositories in Docker Hub.
  • Fargate automatically sets up Cloudwatch metric and logs for your service.
  • Fargate is limited to Application Load Balancers and Network Load Balancers
  • Fargate is currently not supported in all regions. See the full support matrix here

Which service you decide to go with is entirely dependent on your infrastructure needs. If you want to focus entirely on the application you're deploying and not have to worry about servers, clusters and the underlying infrastructure as a whole then Fargate is for you. However, if your application does require you to have fine grained control over the details of the underlying EC2 instances, auto scaling rules etc than ECS is more appropriate.

Questions? Ask away.

We're here to talk about our services, answer any questions, give advice, or just to chat.

Ready to hand off the Gruntwork?