how to debug node.js causing 100% cpu usage?


Question

I have a node app that uses express and redis. On our development server, after a bit of use node starts to use 100% cpu. The application still responds but top reports node using 100%. The cpu doesn't drop until node is restarted.

I have not nailed it down to any particular route or function that is causing it.

What is the best way to diagnose this problem?

I looked at node-inspector with the v8-profiler and it gave me the same error that is reported here https://github.com/dannycoates/v8-profiler/issues/10

1
34
4/16/2012 12:41:26 AM

You can profile your app with node-tick.

  1. Install node-tick by sudo npm -g install tick
  2. Run your app with enabled profile node --prof ./app.js
  3. After some time with CPU 100% usage stop your app
  4. You can see v8.log in your app directory, now you can read it with node-tick-processor
  5. Run node-tick-processor and explain results
  6. Load v8.log into chrome://tracing to analyse as tree.

node js cpu 100%

20
5/23/2017 11:54:50 AM

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon