gpt4 book ai didi

node.js - 每个容器需要多少内存以及cpu nginx和nodejs?

转载 作者:行者123 更新时间:2023-12-02 18:01:10 41 4
gpt4 key购买 nike

我想在AWS ECS中创建任务定义。
我需要在conatiner中运行多少内存和cpu?和nodejs在另一个容器中?
nginx-只是80到3000之间的代理。
nodejs-调用atlas mongodb的简单服务

最佳答案

在ECS中运行容器时,我永远不会建议硬限制。
另外,您无法确定容器空闲状态的内存,因此最好查看Nginx的某些基准,同时 Node 内存因应用程序而异,而且较差的代码可能比良好的托管应用程序消耗更多的内存。
NGINX使用一名工作人员,15%的CPU和1MB的内存来每秒处理11,500个请求。
Benchmarks have shown NGINX lightweight
现在根据您的流量EXPECTED_REQUST/11500 = Required memory虽然 Nodejs 的内存确实很关键,并且如果应用程序未关闭文件或未正确请求,则完全取决于您的代码,它将早于预期到达最大内存,因此请保留内存。
内存保留

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


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.


ECS memoryReservation
因此最好不要设置称为 memory的硬限制。

The amount (in MiB) of memory to present to the container. If your container attempts to exceed the memory specified here, the container is killed. The total amount of memory reserved for all containers within a task must be lower than the task memory value, if one is specified.

关于node.js - 每个容器需要多少内存以及cpu nginx和nodejs?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63077100/

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