Question

My website, CompassionPit.com, is powered by Node.js. I have released the source code; it's hosted at GitHub. The app itself is running on a Linode with 768MB of RAM (I recently upgraded the server; it was at 512MB).

Recently I have been getting CPU usage notifications from Linode: we're increasingly often at 90%+ usage. I called Linode to see what I could do about upgrading my access to CPU resources, but apparently I'm okay for now, since if we max out to 100% then we can spill over into the next 3 cores (Linodes are 4 processor Xen instances).

How can I profile my Node app to see where I'm using up memory and CPU resources? I predict I'll soon need to restructure the application to be run by a multiple server setup, but I intuitively believe that proper profiling will lead to smarter architecture decisions. Please correct me if I'm wrong.

Was it helpful?

Solution

I've had reasonable success using https://github.com/dannycoates/node-inspector for profiling. There's a setup guide at the bottom of the README file.

As of later versions of Node.js, the profiling part of node-inspector no longer functions. I've had reasonable success with --prof (http://code.google.com/p/v8/wiki/V8Profiler) and https://github.com/c4milo/node-webkit-agent as mentioned in the answer below.

OTHER TIPS

Node inspector can't profile node after version 0.6.x

The following plugin has been updated to work with new version of v8 (node 0.7.x +). It's the only one besides nodetime.com that is still working. It uses the actual webkit debugger:

https://github.com/c4milo/node-webkit-agent

It has very clear instructions as well.

As of v6.3.0, you can now run node --inspect your_script.js.

Node will print a URL to the console, which can be opened in Chrome, which will connect you to reveal a fully-functional Web Inspector that you can use to profile the Node process.

Run node --inspect --debug-brk to immediately pause execution (which is handy if you need to start a profiling session as soon as your application starts)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top