Ho to allocate CPU and Mem for ECS cluster ec2 launch type

0

I'm unable to decide where I should specify the cpu and memory while creating the task definition. Should it be done at the infrastructure requirements tab OR should it be specified at containers tab?

Scenario - 2 t3.micro machines registered to the ecs cluster. I want to run 2 java microservices containers What should I specify under infrastructure requirements - Should i give the combined value of 2 micro machines with CPU- 2vcpu and mem as 2 gb? Or Should it be done at container tab by setting the cpu and memory limits - For each container specifying cpu as 1vcpu and mem as 1gb

I had created a task definition where I had specified the cpu as 1vcpu and 0.8gb as memory under infra requirements. This was able to create and run the containers, but it had launched both the containers in the same machine, which was too much for a micro machine and the machine crashed.I even tried adding a placement strategy where I specified for it to spread across instance id's, but it still launched the containers in a single machine. Please provide guidance on this.

已提问 3 个月前132 查看次数
1 回答
1
已接受的回答

Hi,

Specifying CPU and memory at the "Task size" section for Ec2 launch type is optional. If you do not specify here in the task size then the containers' individual requests and limits will be used. In your case, with 2 t3.micro machines, do not combine them in the "Task size" section. Set appropriate CPU and memory requests and limits for each container in the "Containers" tab. Start with conservative values like cpu = 0.5 and memory = 0.5 GiB per container. Monitor resource usage through CloudWatch and adjust these values based on actual needs. You were on the right track with the placement strategy to spread containers across instances. Ensure your strategy uses the "spread" constraint with the specific instance IDs of your t3.micro machines. Alternatively, use the "memberOf" constraint with a Launch Template that specifies multiple machines for placement.

Hope this helps.

已回答 3 个月前
profile picture
专家
已审核 2 个月前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则