- Newest
- Most votes
- Most comments
Hi Ognif,
I apologize for the confusion the Re:Post agent may have caused.
A task holds one or more containers in it (much like a Pod in Kubernetes holds 1 or more containers). You can adjust the CPU and memory reservation size of the task in the “task size” attribute of a task.
Each container in the task can have its own amount of CPU and memory reservations made. For example, a task can have 10 CPU reserved for the entire task but have multiple containers running in it that share that 10 CPU. If the task has two containers and each container reserves 5 CPU then 1 Task of 10 CPU = 1 Container of 5 CPU + 1 Container of 5 CPU.
There is no limit attribute for task size. You can only specify the request/reservation size of a task. There is a limit for container memory (hard limits and soft limits) but not for container CPU usage. Hard memory limits will shut down containers that attempt to go over the hard limit. Soft memory limits will try to keep container resource utilization under the soft limit when possible.
ECS Tasks have a 10 CPU task size limit when running on EC2; however, if you don’t specify a task size then the container limits will be used. For example, an ECS Task is made but without a task size defined. A container in the task is given a 15 CPU reservation amount. The overall ECS task will take on a size of 15 CPU to account for the size of the task’s container.
I hope that helps!
answered 2 years ago
Iam sorry, I do not understand this answer well. You wrote about task level and container level. How to differ? In taskdefinition I have a option addContainer where I can add cpu and memory. In taskDefinition itslef I do not have any parameter for cpu and memory.
answered 2 years ago
In Amazon ECS, the concept of resource allocation is handled differently compared to Kubernetes (EKS). ECS uses a simpler model for specifying CPU and memory requirements for tasks and containers.
For ECS, you define the resource requirements in the task definition. There isn't a direct equivalent to Kubernetes' "requests" and "limits" in ECS. Instead, ECS uses a single set of values for both the minimum guaranteed resources and the maximum allowed resources.
To set resources similar to your EKS example in an ECS task definition, you would specify the CPU and memory at the task level, which represents the maximum resources the task can use. Then, you can optionally specify container-level resources, which must fit within the task-level limits.
Here's how you might set this up in an ECS task definition:
-
At the task level:
- CPU: 6 vCPU (6144 CPU units in ECS)
- Memory: 10 GB (10240 MiB in ECS)
-
At the container level:
- CPU: 4 vCPU (4096 CPU units in ECS)
- Memory: 4 GB (4096 MiB in ECS)
In ECS, the task-level resources act as the maximum limit (similar to Kubernetes' "limits"), while the container-level resources are more like the minimum guaranteed resources (similar to Kubernetes' "requests").
It's important to note that in ECS, if you don't specify container-level resources, the container can potentially use all the resources allocated to the task. This is different from Kubernetes, where requests and limits provide more granular control over resource allocation.
When configuring your ECS task definition, ensure that the sum of all container-level resources does not exceed the task-level resources. This approach allows for some flexibility in resource usage while still providing a degree of control over resource allocation.
Remember that in ECS, CPU is measured in CPU units (1 vCPU = 1024 CPU units) and memory is measured in MiB. Adjust your values accordingly when creating your ECS task definition.
Sources
Best practices for Amazon ECS task sizes - Amazon Elastic Container Service
Foundations - Container Build Lens
answered 2 years ago
Relevant content
asked 2 years ago
- AWS OFFICIALUpdated 8 months ago
- AWS OFFICIALUpdated a year ago

Hi Ognif,
I wanted to follow up on whether the answer I provided below was helpful. If not, then I would be happy to answer any additional questions you may have. If it did, then please upvote and set my answer as the officially accepted answer.