You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

PM2集群模式LoopBack应用无流量内存高、有流量重启求助

LoopBack应用PM2集群模式下内存占用过高问题

我使用PM2以集群模式运行LoopBack应用,其中1个primary实例运行活跃调度器,其余replica实例处理由webhook请求触发的后台任务。启动PM2半小时且无流量时,CPU利用率为0%,但实例内存占用在450MB至1.6GB之间。我们采用Redis和Bull处理任务,有流量时实例会达到max_memory_restart阈值并重启。

环境信息

Nodejs version - 14.19
PM2 version - 5.2.2
Instance - 8CPU and 32 GB RAM

PM2配置文件(ecosystem.config.js)

module.exports = {
  apps: [
    {
      name: 'primary',
      script: 'dist/index.js',
      instances: 1,
      exec_mode: 'cluster',
      autorestart: true,
      watch: false,
      time: true,
      pmx: false,
      max_memory_restart: '3G',
      env: {
        NODE_ENV: 'development',
      },
      env_production: {
        NODE_ENV: 'production',
      },
    },
    {
      name: 'replica', 
      script: 'dist/index.js',
      instances: '-1',
      exec_mode: 'cluster',
      autorestart: true,
      watch: false,
      time: true,
      pmx: false,
      max_memory_restart: '3G',
      env: {
        NODE_ENV: 'development',
      },
      env_production: {
        NODE_ENV: 'production',
      },
    },
  ],
};

内存占用截图

内存占用截图

恳请各位指导如何解决该问题?


内容的提问来源于stack exchange,提问作者Varun Nayyar

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.01 19:42:43