Air off, Mind on ~ / Javascript+Golang, Sci, Health… /

Profiling Node.JS Application


Call something like “ulimit -n 8192” in your NodeJS App start shell script, before start your nodejs service.

Running with –prof to generate the v8.log

node --prof --prof_lazy app.js

with tools in /node/deps/v8/, you can get report like following:

(run tools/linux-tick-processor path-of-v8.log)

[Shared libraries]:
   ticks  total  nonlib   name
      3    0.0%    0.0%  .../libc-2.13.so

   ticks  total  nonlib   name
      1    0.0%    0.0%  Stub: InstanceofStub

   ticks  total  nonlib   name
     1    0.0%    0.0%  __write

   ticks  total  nonlib   name
     15    0.0%

[Bottom up (heavy) profile]:
  Note: percentage shows a share of a particular caller in the total
  amount of its parent calls.
  Callers occupying less than 2.0% are not shown.

   ticks parent  name

trace log

strace -o trace.log -cf node app.js:

or simple get the time

time node app.js

Other Modules & Tools

read the nodejs blog http://blog.nodejs.org/2012/04/25/profiling-node-js/

dtrace -o stacks.out -n 'profile-97/execname == "node" && arg1/{
  @[jstack(100, 8000)] = count(); } tick-60s { exit(0); }'
  • v8-profiler

@Github https://github.com/dannycoates/v8-profiler

var profiler = require('v8-profiler');


  • node-inspector

@Github https://github.com/dannycoates/node-inspector

node --debug app.js
  • node-profiler

@Github https://github.com/bnoordhuis/node-profiler

var profiler = require('profiler');
// <here be code you don't want to profile>
// <performance critical code here>

Nodetime reveals response time and other internals of HTTP requests and underlying HTTP / database calls in your Node.js application. Coupled with related process and OS state information it enables tracing performance problems down to the root cause. Nodetime supports multiple native and external APIs and libraries.

var nodetime = require('nodetime');
nodetime.on('session', function(id) {
  // do something with session id here
  • Callgrind

Callgrind is a profiling tool that records the call history among functions in a program’s run as a call-graph. By default, the collected data consists of the number of instructions executed, their relationship to source lines, the caller/callee relationship between functions, and the numbers of such calls. Optionally, cache simulation and/or branch prediction (similar to Cachegrind) can produce further information about the runtime behavior of an application.


valgrind --tool=callgrind node app.js