Simple AWS #4: ECS
A quick overview of ECS, a pricing analysis and 3 workshops.
Welcome to Simple AWS! A free newsletter that helps you build on AWS without being an expert. This is issue #4. Shall we?
AWS Service: Elastic Container Service
tl;dr: It's a container orchestrator (like Kubernetes) but done by AWS. You pick a Docker app, set parameters like CPU and memory, set up an EC2 Auto Scaling Group or use Fargate (serverless, you pay per use), and ECS handles launching everything and keeping it running. Here's a better explanation of what's involved:
- Cluster: It's a container for everything. It defines where the capacity comes from (EC2 or Fargate) and contains all the other resources.
- Task Definition: It's a blueprint for Tasks. A Task is an instance of a Task Definition (like objects and classes in OOP, this one's the class). The Task Definition is where you set things like:
- The Docker image
- CPU and memory
- Launch type (EC2 or Fargate)
- Logging configuration
- The IAM role
- Task: An instance of a Task Definition. This is basically your container running. The ECS Task Scheduler handles creating the tasks, placing them and creating new ones as needed.
- Service: A grouping of Tasks (with the same Task Definition), with a Load Balancer in front of them.
- ECS is easier than k8s. If you're starting from scratch, don't have anything in k8s yet and don't plan to move from AWS, go with ECS.
- If you already have some stuff on k8s or already know how to use it, use EKS (managed Kubernetes cluster in AWS). You can also use Fargate there if you want.
- ECS is free. You only pay for the EC2 instances or Fargate capacity and the Load Balancers. In contrast, an EKS cluster costs $72/month.
- Fargate is awesome for unpredictable loads, and scales extremely fast (you still have to wait for the container to start). Plus, you can use savings plans!
- In contrast, EC2 is cheaper, but when scaling you need to wait for the EC2 instance to start.
- Here's the pricing (without savings plans) for 2 tasks running continuously, each with 1 vCPU and 4 GB of memory:
- And here's a much more complete analysis.
- Here's a reference architecture of microservices deployed on ECS and exposed with API Gateway.
- And here's how to create a CI/CD pipeline with:
AWS Copilot CLI is a tool that lets you deploy production-ready, scalable services on AWS from a Dockerfile in one command.
Want to learn more about ECS? Check out (all by AWS):
ECS? Good and easier.
Pick one and go build!
And one for anyone yelling at me for suggesting something that locks you in with AWS:
There is a use case for it,
But the cost is huge.
I actually have a blog too, but it's mostly just sitting there. However, this issue inspired me to write an article about vendor lock-in and why it's not as bad as it sounds. Let's hope I can get it out before Christmas!
Thank you for reading! See ya on the next issue.