Skip to content

Instantly share code, notes, and snippets.

@jondot
Forked from balupton/README.md
Created May 12, 2013 11:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jondot/5563296 to your computer and use it in GitHub Desktop.
Save jondot/5563296 to your computer and use it in GitHub Desktop.

Debugging & Profiling Node.js

This is a maintained listing of all the different ways to debug and profile Node.js applications. If there is something missing or an improvement, post a comment! :)

Interactive Stack Traces with traceGL - Shareware

  1. Guide here

Profiling with Profiler

  1. Install globally npm install -g profiler
  2. Start your process with node --prof this will create a v8.log file
  3. Build nprof by running /Users/balupton/.nvm/v0.8.22/lib/node_modules/profiler/tools/build-nprof
  4. Run /Users/balupton/.nvm/v0.8.22/lib/node_modules/profiler/nprof this will read the v8.log profile and give you nice ouput

CPU and Memory Profiling with NodeTime

  1. Install to your app npm install nodetime
  2. Include in your app require('nodetime').profile()
  3. Follow the instructions it will output to console

Wekit Inspector Debugging with Node Inspector

  1. No longer supported unfortunately, however usually works if you downgrade: npm install -g node-inspector@0.1.10
  2. Run your app in debug mode: node --debug-brk your/node/program.js
  3. In another terminal window run node-inspector: node-inspector
  4. Open http://127.0.0.1:8080/debug?port=5858

Webkit Inspector Profiling with Node Webkit Agent

  1. Install to your app npm install webkit-devtools-agent
  2. Include in your app agent = require('webkit-devtools-agent')
  3. Activate the agent: kill -SIGUSR2 <your node process id>
  4. Access the agent via the appropriate link

Flamegraphs with Dtrace and StackVis

  1. Only supported on SmartOS

Benchmark with Apache Bench

  1. Benchmark a ton of requests to your server ab -n 100000 -c 1 http://127.0.0.1:9778/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment