Reputation: 1
Pm2 fails to restart when CPU Utilization reaches 80%. I noticed that this mostly happens when I send mail.
Do you think this problem is related to a memory leak or nodemailer?
Here I have added my code.
var smtpTransport = nodeMailer.createTransport({ host: 'myhostname', port: 465, secure:true, tls:{ rejectUnauthorized:false }, auth: { user: <>, pass: <> } })
var mailOptions = {
from: <<email>>,
to: <<email>>,
subject: '<<my text>>',
html: <<text>>
};
smtpTransport.sendMail(mailOptions, function(err,res){
if(err)
{
console.log(err);
}else{
console.log(res.response);
}
});
Upvotes: 0
Views: 2369
Reputation: 151
Pm2 does not restart your application when it reaches high CPU, you can only specify a memory limit at which Pm2 will restart your app, as specified in the Docs http://pm2.keymetrics.io/docs/usage/memory-limit/ .
That being said crashing your server when it reaches a high CPU usage caused by executing a workload is not the way to go.
When your server reaches 80% of its capacity it either means that you have unoptimized code/leaks or you need to scale.
Upvotes: 1