node.js dev ops
DESCRIPTION
Development, monitoring and management tools for Node.js applicationsTRANSCRIPT
Shubhra Kar@shubhrakar
April, 2014
DevOps
Module reference
http://strongloop.com/get-started/
npm install –g strong-cli
Node.js modules (Sample set)
3
Node.js Core
strong-module-loader
strong-cluster-connect-
store
strong-cluster-control
SL-Config
Loopback Strong-mq
strong-task-emitter
Engine.io Mongoose
Strong-agent
strong-cluster-
socket.io-store
strong-config-loader
Request
Node-heapdump
Asynch
node-inspector
Passport
Strong-remoting
Q
EJS
Express
Connect
Socket.IO
Reggie Postgres Connector
Oracle Connector
SQL ServerConnector
MongoDBConnector
REST Connector
In-Memory connector
LIBUV
V8 Profiler
SOAP connector
ATG connector
iOS Remoting
& SDK
Angular& SDK
Android Remoting
/SDK
Setting up StrongOps
With SLC
$ slc strongopsfollow registration instructions$ sl run
W/O SLC
$ slc strongops$ npm install - - save strong-agentrequire(‘strong-agent’).profile();$ node app
http://docs.strongloop.com/display/DOC/Setting+up+StrongOps+monitoring
Debugging
http://docs.strongloop.com/display/DOC/Debugging+with+Node+Inspector
Debug mode
$ npm install –g node-inspector$ slc run$ slc debuGo to http://localhost:8080/debug?port=5858
Running mode
$ pgrep –l node$ 2345 node your/node/server.js
$ kill –s USR1 2345
Running with mocha
Pass –debug –brk optionLaunch node inspector
Error Detection
http://docs.strongloop.com/display/DOC/Error+reportingDomain basedZones will change the world !
CPU profiling
http://docs.strongloop.com/display/DOC/Profiling
StrongOps - Memory Profiling and Leak Detection
A nasty one ! (memory leak)
heapdump for V8 snapshots by @bnoordhuis
npm install heapdumpAdd to app : var heapdump = require(‘heapdump’)
Method 1 : writeSnapshot
Method 2 : SIGUSR2 (Unix only)
Make sure your directory is writable
var heapdump = require('heapdump')...heapdump.writeSnapshot()
kill –USR2 <pid>
process.chdir('/path/to/writeable/dir’)
heapdump for V8 snapshots by @bnoordhuis
Programmatic heap snapshots (timer based)
Programmatic heap snapshots (threshold based)
var heapdump = require('heapdump') ... setInterval(function () { heapdump.writeSnapshot() }, 6000 * 30) <strong>(1)</strong>
var heapdump = require('heapdump')var nextMBThreshold = 0 <strong>(1)</strong>
setInterval(function () { var memMB = process.memoryUsage().rss / 1048576 <strong>(2)</strong> if (memMB > nextMBThreshold) { <strong>(3)</strong> heapdump.writeSnapshot() nextMBThreshold += 100 }}, 6000 * 2) <strong>(4)</strong>
12
Heapdump analysis in Chrome Dev Tools
13
Heapdump analysis in Chrome Dev Tools
Supervisor - Runtime
http://docs.strongloop.com/display/DOC/Strong+supervisor
usage: slc run [options] [app [app-options...]]usage: slr [options] [app [app-options...]]
Help, detach, version, log, pid, cluster, no-profile
Cluster Management and Control
http://docs.strongloop.com/display/DOC/Clustering+applications
slc clusterctl [options] [command]
Status, Set-size, Start, Stop, Restart, Fork, disconnect
DevOps Tools - Private Registry
Strong Registry
npm client
npm client
public npmjs
registry
Other upstream registries
metadata packag
es
indexes
• white/black list• audit
• security• cache
Pluggable Stores
① Private & multi-registry② On-premises, private or
public cloud support③ Module Whitelisting④ Audit⑤ Configuration Mgmt.⑥ CI and Build Mgmt.
Transaction and end-point tracing
Performance Monitoring
Performance Monitoring
Alerts
Open Data API
22
Good references
Memory Analysis 101 :https://developers.google.com/chrome-developer-tools/docs/memory-analysis-101
Taming the Unicorn: Easing JavaScript Memory profiling in Chrome DevTools :http://addyosmani.com/blog/taming-the-unicorn-easing-javascript-memory-profiling-in-devtools/
StrongOps : http://strongloop.com/node-js-performance/strongops/