내용으로 건너뛰기

Understanding memory in ECS EC2 task

0

How can I tell an ECS container that it cannot use more than 10GB of memory?

I don't give the task any limits because I need alltogether in all container more than 10 CPU units and EC2 has a limit of 10 CPUs in the task definition.

In the container definition I give the container a memoryReservationMiB of 10GB and cpu of 6. But the container doesn't seem to care. I want to prevent the container from terminating if too much memory is used, so I don't set memoryLimitMiB but only memoryReservationMiB.

Unfortunately the application crashes in the ECS EC2 task with a memory error, but in EKS the container runs through with the same settings.

          resources:
            requests:
              cpu: "4"
              memory: "4Gi"
            limits:
              cpu: "6"
              memory: "10Gi

Is the approach wrong?

1개 답변
5

Hello,

When creating a Task Definition on ECS, you can set the CPU and memory allocation in the Resource allocation limits field (see screenshot below). If you've set CPU to 6 vCPU and Memory soft limit to 10GB it should work. If your container is crashing, have you checked if your EC2 instance can actually handle more than 10GB of memory? Also, do you know how much memory your task might actually need at peak usage?

Hope it helps :)

Enter image description here

전문가

답변함 2년 전

전문가

검토됨 2년 전

  • I have a EC2 with 16 CPU and 64 GM Memory I think this is not the issue. The container contains a modern software and a modern software consume as much memory it can get. So I think the problem is that ECS will not limit the memory, it will just terminate the container if the limit is reached. EKS will not and I ask me why. Is there no powerful task possible on ECS?

  • What about your application logs, the ecs agent logs? Why not trying to configure at least the memory for the task?

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

관련 콘텐츠