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 個月前檢視次數 134 次
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 個月前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南