9

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.

1
  • CompassionPit.com appears to be gone, for anyone coming to this post several years later. Commented Apr 3, 2013 at 16:55

3 Answers 3

2

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.

Sign up to request clarification or add additional context in comments.

3 Comments

This is not true anymore. Node inspector has been updated in the meantime.
@LeoKoppelkamm Where are you seeing that Node Inspector supports profiling? The README still states "Profiler is not implemented yet".
I was refering to the 0.6.x comment. Node inspector was completely broken for a while, but that has been fixed in the mean time. I'm gonna edit the answer to clear that up.
2

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)

Comments

1

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.

1 Comment

I would like to chime in that from the #Node.js channel on Freenode, people have also suggested dtrace (credit: H4ns) and v8-profiler (Glenjamin).

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.