admin管理员组文章数量:1122832
I was trying to start my nextjs 14.2 app using pm2.
at first, i tried to use:
pm2 start npm --name "Next" -i max -- start
command. everything is ok and it use about 70MB of ram.
than i tried to start the exactly same app, using configuration file: ecosystem.config.js
module.exports = {
apps: [
{
name: 'maApp',
exec_mode: 'cluster',
instances: 'max',
script: './node_modules/next/dist/bin/next',
args: 'start',
exp_backoff_restart_delay: 100,
watch: false,
max_memory_restart: '150M',
autorestart: true,
}
]
}
then i found out, that 2nd way takes much more ram and cpu - ~150MB at zero requests, under load it could take ~1.2GB of ram.
if u go to the pm2 monit
, you should be available to see, that with 1st method, the script path is /root/.nvm/versions/node/v21.6.2/bin/npm
; 2nd - ./nextjs_test_fast/node_modules/next/dist/bin/next
.
So:
- where this big difference coming from?
- which way to run app is more suitable?
- is there any way to reduce the memory consumption from 2nd method?
- is there any way to start cron job to reload apps, not restarting it (without scripts)?
PS
also, using 1st method, the app do not updating cache files and to fix this, i'm using pm2 reload
command and everything starts working normal.
Nextjs - 14.2 pm2 - 5.4.0 node - 21.6.2 npm - 10.2.4 nvm - 0.39.7
本文标签: linuxNextjs and PM2 on ubuntu serverStack Overflow
版权声明:本文标题:linux - Nextjs and PM2 on ubuntu server - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736299646a1930532.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论