Reputation: 1586
I have an express.js
app running in cluster mode (nodejs cluster module) on a linux production server. I'm using PM2
to manage this app. It usually uses less than 3% CPU. However, sometimes the CPU usage spikes up to 100% for a short period of time (less than a minute). I'm not able to reproduce this issue. This only happens once a day or two.
Is there any way to find out which function or route is causing the sudden CPU spikes, using PM2? Thanks.
Upvotes: 1
Views: 3140
Reputation: 306
i think have some slow synchronous execution on some request in your application.
Upvotes: 3
Reputation: 418
My answer is based purely on my experience with the topic
For both tests try to use tool like JMeter where you can put your one/multiple endpoints and run loads of them in period of time while monitoring CPU & MEMORY Usage.
memory leak
from the APIs themselves.map()
, .reduce()
for huge arrays?reboot
?
if yes, then you need to suspect that the express app experiencing memory leak
and Garbage collector trying to clean the mess.1.5X
more requests.Upvotes: 1