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ヶ月前

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン

関連するコンテンツ