简体   繁体   中英

What is the minimum system requirement to run nodejs app with pm2?

我是pm2概念的新手,我面临的问题是我的cpu使用率增加并达到100%的内存,并且服务器因网站崩溃而关闭,因此任何人都可以对此进行咨询。我是否需要更改配置我的生产(活动)服务器(例如增加内存)?我的代码也是必要且足够的。我是ec2用户。

The system requirements will mostly depend on your application which you told nothing about. If CPU reaches 100% then you likely have some tight loop that is actively adding delays by burning cycles synchronously or something like that. The 100% memory usage can mean memory leaks and in that case no RAM will be sufficient because leaking memory will use up all your RAM eventually, no matter how large it is.

You need to profile your application with real usage patterns on a system where that app works and only then you will know how much resources it needs. This is true for every kind of application.

Additionally if you notice that resources usage grown over time then it may be a sign of some resource leaking, like memory leaking, spawning processes that don't exit but use CPU and RAM, etc.

first of all i would like to suggest you to follow these guideline for production envoiremnt.

1) disable morgon if you enable it as a dev envoiremnt. 2) use nginx or pm2 for load balancing. or you can easily handle load balancing by using this command

pm2 start server.js -i 10

3)handle uncaugh exception. ie:

process.on("uncaughtException".function (err){
//do error handling 
})

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM