Amazon ECS basics
AWS ECS is a service for you to store, run, deploy container images on the cloud. You can also easily configure an autoscaling group so that your service would can scale horizontally.
A ECS cluster is a group of container instances for you to run some tasks.
You can monitor metrics like the number of running containers, Cpu and memory usage of a cluster. In theory the number of running containers would equal to the number of running EC2 instance that is scale automatically.
A task is used to run Docker containers in Amazon ECS. A task may spread to multiple EC2 instances and the relationship is monitored by something called ECS service.
A service auto-recovers any stopped tasks to maintain the desired number of tasks that you specify.
- Load balancer target group
A sample configuration that works
- Go to this link: https://us-west-2.console.aws.amazon.com/ecs/home?region=us-east-1#/firstRun and you can launch a cluster with the most basic settings.
- There is one thing called
Cpu unityou need to change in the default setting. Each single core Cpu have 1024 units. You can decide how many tasks to run on a single Cpu using this parameter. Let’s say you have a process that takes up 300 Cpu units so you should be able to launch 3 processes using that single Cpu core.
To make things simple if you want to run exactly 1 process in each container you can specify a number like 513 in the box (instead of the default value 10)
Other than that you can keep clicking the next button with default settings until you successfully started the cluster.
How it works using the default setting is it will launch an container instance using
httpd:2.4 container image and insert a tiny html page to it. So if you go visit the EC2 instance’s address you will see the following screen (provided the EC2 instance is not behind a load balancer).
- Now your default cluster is up, it’s time to configure your auto-scaler.
The way Auto-scaler works is that it will check the EC2 or load balancer’s Cpu and memory usages using AWS CloudWatch and detects if there’s something that needs to be done. Once the Auto-scaler receives the signal from CloudWatch it will scale up or down according to your settings which is very sweet.
Check your ECS logs here:
28 Jun 2017