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.

1 réponse
1
Réponse acceptée

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.

répondu il y a 3 mois
profile picture
EXPERT
vérifié il y a 2 mois

Vous n'êtes pas connecté. Se connecter pour publier une réponse.

Une bonne réponse répond clairement à la question, contient des commentaires constructifs et encourage le développement professionnel de la personne qui pose la question.

Instructions pour répondre aux questions