aws / aws-cdk

The AWS Cloud Development Kit is a framework for defining cloud infrastructure in code
https://aws.amazon.com/cdk
Apache License 2.0
11.6k stars 3.9k forks source link

(ApplicationLoadBalancedFargateService): Container size won't update #13127

Open tai-acall opened 3 years ago

tai-acall commented 3 years ago

Once the ECS stack first time deployment done, even I change the container size setting in CDK and run deployment command it won't update the ECS task size.

Reproduction Steps

  1. Build a ECS Stack with ApplicationLoadBalancedFargateService construct class with memoryLimitMiB and cpu option
  2. run deploy command
  3. change the value in memoryLimitMiB and cpu option
  4. run deploy command again

What did you expect to happen?

the task size should change to the latest value as define in CDK.

What actually happened?

the task size still as the first time deployment setting.

Environment

Other


This is :bug: Bug Report

JacobTheEvans commented 3 years ago

I am experiencing the same issue did you ever find a work around @tai-acall?

tai-acall commented 3 years ago

I have side containers in my work, so I let the memory limitation of ECS service as variable then setting each container limitation separately. that will trigger the deploy process because the task definition will be changed while the ECS service limit be changed and limitation of each container will be changed too.

ex: ECS Service memory = 1024 Container A memory usage limit = 512 Container B memory = ECS Service memory - Container A memory usage limit

ECS Service memory = 2048 Container A memory usage limit = 512 Container B memory = ECS Service memory - Container A memory usage limit -> Task definition changed !

I know this is not the best way to do that but might the easiest way in my work.

I hope this will help. @JacobTheEvans

JacobTheEvans commented 3 years ago

Thanks @tai-acall ! I found a different solution.

Solution As I dug deeper what I found was that memoryLimitMiB and cpu in ApplicationLoadBalancedFargateService is not used as the default for the containers. I went into the documentation here and found the following under the memoryLimitMiB section: This default is set in the underlying FargateTaskDefinition construct Meaning that if you want the default to be set each of the containers without having to manually set it you must add the memoryLimitMiB and cpu keys to the FargateTaskDefinition

TLDR Set memoryLimitMiB and cpu in FargateTaskDefinition not in ApplicationLoadBalancedFargateService

gnagy commented 2 years ago

I found a related issue, sorry for piggybacking on this one, let me know if I should open a separate ticket.

The latest docs for setting memory limits recommends to set it both at the task and container level, so apps like Java can observe the limits set: https://aws.amazon.com/blogs/containers/how-amazon-ecs-manages-cpu-and-memory-resources/

[Update 12/11/2020] Some applications are container-aware and can configure themselves to take full advantage of the resources available inside the container. The latest versions of Java are a good example of this pattern. For this reason, some of these applications work best when CPU and memory resources are explicitly configured at the container level, in addition to the configuration at the task level. In other words, while containers without specific resource configurations can nominally access all task resources, some applications will interpret this configuration differently and may artificially limit the amount of resources they think are available to the container.

Would it be feasible to also set memoryLimitMiB also in ContainerDefinitionOptions in ApplicationLoadBalancedServiceBase ?

peterwoodworth commented 2 years ago

merged in #21201

github-actions[bot] commented 2 years ago

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.