I am trialling AWS ECS for the first time. I've run through the tutorials and now I'm trying to deploy an existing Docker Compose suite which I've been using on Digital Ocean for some time.
I have four containers in my composition, an ExpressJS app, NGinx, MemcacheD, and a Python Flask API. These work OK on a Digital Ocean 1GB RAM host.
I've been following the guide and specs here: https://github.com/aws/amazon-ecs-cli#launching-an-aws-fargate-task and other general ECS CLI guides.
I've got ECS to make the cluster+service from the docker YAML (with a few tweaks), but when I try to UP the service, I get an error that the t2.micro EC2 which Fargate boots isn't big enough:
INFO (service CI) was unable to place a task because no container instance met all of its requirements. The closest matching (container-instance ...) has insufficient memory available. For more information, see the Troubleshooting section of the Amazon ECS Developer Guide.
So I'd like to force it to boot an t2.small (2GB RAM) or higher.
I see that you cannot directly tell Fargate to use a specific instant type from ECS - that setting is only for "EC2" direct, but I want to use Fargate to automate the instance management.
I have tried using the
task_size memory parameter (which I believe to be the correct way of informing Fargate of your application's requirements?) but this doesn't affect the choice of EC2 instance type which Fargate boots - it still boots the default t2.micro.
I added this YML file with
version: 1 task_definition: task_size: cpu_limit: 512 mem_limit: 2GB
When I rebuild my cluster from scratch with this definition, I can see the 2GB is correctly configured under the taskDefinition page (
console.aws.amazon.com/ecs/home#/taskDefinitions/...) - so the configuration is provided OK, but when I view the instance it's booted, it's still a t2.micro with 1GB RAM.
Am I misunderstanding the task_size.memory parameter?
I was mistaken in thinking the 2GB setting would influence the host instance size. This is not the case:
ecs-cli up brings up the cluster and instance long before the docker-specified services are created by
ecs-cli compose service up which reads those task params.
The task size parameter is per TASK which in Docker Compose terms are "services" (I think of them as containers plus exec params). So as I have four services, there will be four ECS tasks. To get the four tasks to fit inside a 1GB host therefore, task size should be 256MB (not 2GB!)
task_definition: task_size: cpu_limit: 512 mem_limit: 0.5GB
This now gets further creating the services, without the memory error. I don't quite understand why (as 0.5GB x 4 is still too big).
So while this has avoided the error, I still want to know how to create a larger instance when performing
ecs-cli up with Fargate.