如何允许 pm2 使用所有可用的系统内存

how to allow pm2 to use all of the available system memory

我有多个用 Node 和 运行 在 pm2 上编写的微服务。每当这些微服务中的任何一个出现高流量时,即使系统有超过 10GB 的可用内存,内存也不会超过 800 MB。相反,系统变慢了。我只使用了下面的命令,没有额外的设置来启动服务。

pm2 start app.js --name='app_name'

我已经浏览了 pm2 的文档,但它只提到使用 max-memory-restart 限制内存使用。有什么方法可以确保我的微服务使用所有可用的系统内存。

Whenever there is a high traffic on any of these micro-services, the memory doesn't exceed 800 MB even though the system has more than 10GB of memory free. Instead the system becomes slow.

您还需要查看 CPU 指标,而不仅仅是内存。更有可能的是,这些服务并不缺乏内存,而是会开始换出到磁盘,但只是在您服务器的 CPU 上工作。

分析您的服务也没有什么坏处,可以找出在高负载期间发生的任何可能的瓶颈或停顿。

Is there a way I can make sure my micro-services use all the available system memory.

是的,有:在这些服务中使用更多内存。除非您配置了一个,否则没有内在限制。