1

I am new to pm2 concept,I am facing problem where my cpu usage increases and reaches upto 100% memory and my server goes down resulting to crashing of website,so can anyone please consult me on this.Do I need to change the configuration of my production(live) server such as increasing memory?My code is also neccessary and sufficient.I am ec2 user.

2 Answers2

0

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.

rsp
  • 107,747
  • 29
  • 201
  • 177
0

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 
})
Osama Bari
  • 597
  • 3
  • 15