gpt4 book ai didi

amazon-ecs - memoryReservation 在带有 Fargate 的 ECS 上实际上做了什么?

转载 作者:行者123 更新时间:2023-12-05 06:25:41 27 4
gpt4 key购买 nike

ECS 的容器定义允许您指定 memoryReservation对于每个容器:

The soft limit (in MiB) of memory to reserve for the container. When system memory is under contention, Docker attempts to keep the container memory to this soft limit; however, your container can consume more memory when needed, up to either the hard limit specified with the memory parameter (if applicable), or all of the available memory on the container instance, whichever comes first. This parameter maps to MemoryReservation in the Create a container section of the Docker Remote API and the --memory-reservation option to docker run...If you specify memoryReservation, then that value is subtracted from the available memory resources for the container instance on which the container is placed; otherwise, the value of memory is used. For example, if your container normally uses 128 MiB of memory, but occasionally bursts to 256 MiB of memory for short periods of time, you can set a memoryReservation of 128 MiB, and a memory hard limit of 300 MiB. This configuration would allow the container to only reserve 128 MiB of memory from the remaining resources on the container instance, but also allow the container to consume more memory resources when needed.

我相信这是使用 cgroups 的“soft limits ”实现的。

这意味着,在 ECS+EC2 上,此选项的目的是允许您在一个实例上安排一组任务,如果这些任务都同时使用了最大内存,将超过实例上可用的总内存例如,但您预测他们不会那样做。

但是在 ECS+Fargate 上呢? Fargate 有一个 task size并且任务容器的组合硬限制(“内存”选项)不能超过任务大小的内存。 [这最后一部分是错误的;请参阅我的澄清答案。] 你是 billed based on the task size无论您设置的内存限制如何。那么,通过将 memoryReservation 设置为低于硬限制,您可以获得什么好处?

我能想到的唯一可能性是:

  1. memoryReservation 指示 AWS 将您的容器打包到较少数量的底层 VM 上,冒着性能问题的风险对您没有好处(因为价格相同)。
  2. AWS 只是忽略 Fargate 的 memoryReservation

我是否错过了任何可能性?如果不是,亚马逊会说明它是两者中的哪一个吗?

最佳答案

如果您在单个任务中有多个容器,情况会怎样?您可能希望为一个容器保留一定量的内存。此外,您可能会遇到不同容器同时需要大量内存的情况,并且您不希望它们中的任何一个占用太多内存并拖慢其余容器。

关于amazon-ecs - memoryReservation 在带有 Fargate 的 ECS 上实际上做了什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56795256/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com