If memory and CPU limits are set in AWS for one container, the platform assigns the memory and CPU according to the AWS configuration.
If there are memory and CPU limits set in AWS for more than one container the platform assigns the minimum required memory and CPU to each container, then distributes the remaining memory and CPU among all containers.
Example 1
You have two containers with the following attributes:
-
Container 1: 14 MiB minimum memory, 51 Mib maximum memory
-
Container 2: 17 MiB minimum memory, 36 MiB maximum memory
You create a task that has a task memory limit of 51 MiB, and a task CPU limit of 128.
The platform first assigns the minimum amount of required memory to each container, which is 15 MiB and 17 MiB. Next, the platform divides the remaining allocated memory - 20 MiB - by the amount of containers, and distributes the memory to each container. As a result, the containers will have 24 MiB and 27 MiB allotted to them respectively, which is well under the maximum memory requirement. Because there was no CPU limit set on the containers, the CPU is simply divided among the containers, resulting in each container receiving 64 CPU units.
Example 2
You have four containers with the following attributes:
-
Container 1: 2 MiB minimum memory, 14 MiB maximum memory
-
Container 2: No minimum memory requirement, 50 MiB maximum memory requirement
-
Container 3: No minimum or maximum memory requirements
-
Container 4: No minimum or maximum memory requirements
You create a task that has a task memory limit of 500 MiB and a task CPU limit of 131 CPU units.
The platform first assigns the minimum amount of required memory to each container that specified a minimum memory requirement. Container 1 receives 2 MiB during this step. Next, the remaining memory, 498 MiB, is divided among the four containers. Because 498 does not divide evenly by 4, the result – 126.500 - is rounded down to the thousandths place and then distributed to each container.
As a result, the containers each receive the following memory:
-
Container 1: 126.5 MiB
-
Container 2: 124.5 MiB
-
Container 3: 124.5 MiB
-
Container 4: 124.5 MiB
There was no CPU limit set on the containers, so the CPU units are simply divided among the containers. Because 131 does not divide evenly by 4, the result – 32.750 - is rounded down to the thousandths place and then distributed to each container. As a result, the containers each receive 32.75 CPU units.