How to use profilers with Meteor?

The server-side My Meteor application (the node process) uses much more CPU than would be acceptable, and I want to explore it.

Two concurrent clients use node to use 100% CPU. This is probably due to the massive use of observers, but I need to research it before changing the entire application.

So what tool can I use to profile it? How to use it?

+6
source share
5 answers

APM, application performance monitoring , is a Meteor package + cloud service developed by Arunoda Suziripala of fame MeteorHacks. This is in beta now and it looks very promising:

calls

On the Expensive Calls tab, you can expand the methods and define those that take more time:

screenshot

This 1-minute instructional video only shows you the identification of the expensive methods that you probably want.

Other screenshots

more screenshots

+3
source

You should also look at the Meteor-specific Observatory . This is a powerful server and client logging package with support for profiling arbitrary functions and "automatic logging of template life cycle methods, data collection methods (only search is still supported), and subscription profiling."

+3
source

The best solution I found is v8-profiler (plus node-inspector ).

Installation

  • Go to [Meteor installation folder]/dev_bundle/lib/node_modules .

  • exec $ npm install v8-profiler .

  • Add to server code:

 Meteor.startup(function() { profiler = __meteor_bootstrap__.require("v8-profiler") Meteor._debug("Server started!"); }); 
  • this method will be soon

Using

  • Wherever you are in your application server code, you can configure this profile as follows:

     profiler.startProfiling("name"); //begin cpu profiling yourCode(); var cpuProfile = profiler.stopProfiling("name"); //finish cpu profiling 
  • Remember to run node-inspector

+3
source

NodeTime is a pretty awesome profiling service. It's free, which is especially useful in situations like yours and is very easy to configure!

+2
source

There now

console.time('myFunction'); myFunction(); console.timeEnd('myFunction') //Outputs: myFunction: xxxxms

which I just checked that it works using Meteor 1.2. Super simple, simple and built-in.

0
source

All Articles