2014년 12월 14일 일요일

How to get V8 GarageCollection-related metrics in Node application

I am trying to determine if the GC behavior for a Node application. What's the recommended way to have Node application get some information like:
1. V8 heap size at each minute
2. # of GCs in a second 
etc. 

From what I see in Google, there are some commercial products from AppDynamics & NewRelic, but haven't seen much beyond that. Any suggestions?



place this code at start of index.js it will provide memory usage statistics for every 30,000 milliseconds


var util = require('util');
setInterval(function() {
console.log(util.inspect(process.memoryUsage()));
}, 30000);

i.e
{ rss: 40812544, heapTotal: 32171264, heapUsed: 18636952 } 

Where in 
rss = residential set a.k.a. the pages that are actually in memory
heap(Total|Used) = the chunk of memory that's used for dynamic
allocations



I've also been trying to find good ways of measuring GC related stuff lately. Havent found a simple answer yet, seems like there's no way around native bindings to get a hold of the real nitty gritties.
There's a small list of modules on npmjs.org matching "gc" atm, i.e. node-gc. Unfortunately I havent been able to try any of them yet..
Also there might be some inspiration in StrongLoops commercial strong-agent module which gather tons of detailed metrics.
Thanks for the information, Philip. That's my impression as well. I'd be hesitant to use a module that has not been battle-tested in production environment. The other way I can think of is to throw some simulated prod traffic to my node app with UMEM_DEBUG turned on. This is inspired by https://www.joyent.com/blog/walmart-node-js-memory-leak It would require significant analysis on the memory trace although and not a fit for real-time monitoring. 
I just stumbled upon the new core module "tracing". Its part of v0.11 so this is more for future reference than production use for most projects I guess.
It brings with it a gc-event which seems promising with before / after stats: https://github.com/joyent/node/blob/master/doc/api/tracing.markdown#v8
I just stumbled upon the new core module "tracing". Its part of v0.11 so this is more for future reference than production use for most projects I guess.
It brings with it a gc-event which seems promising with before / after stats: https://github.com/joyent/node/blob/master/doc/api/tracing.markdown#v8
My understanding is that this API (and possibly the underlying implementation in src/node_v8.cc) will be removed shortly, so I wouldn't count too much on it.
I just stumbled upon the new core module "tracing". Its part of v0.11 so this is more for future reference than production use for most projects I guess.
It brings with it a gc-event which seems promising with before / after stats: https://github.com/joyent/node/blob/master/doc/api/tracing.markdown#v8
My understanding is that this API (and possibly the underlying implementation in src/node_v8.cc) will be removed shortly, so I wouldn't count too much on it.
 
I just realized that I should have said that this API and its implementation will probably _change_ in the near future. They won't necessarily be removed. See http://logs.libuv.org/libuv/latest#23:20:01.518 for more information.
Sorry for the confusion,

댓글 없음:

댓글 쓰기