Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to trigger profiling in NodeJS at runtime?

We have a very stateful NodeJS based web server (Meteor) that occasionally, randomly becomes slow in production. The problem is not reproducible in any of our tests, and we don't know what's triggering it.

To diagnose this, we are using the v8-profiler package. This lets us trigger a 10-second CPU profile and download it for offline analysis.

Despite not having received any commits in 3 years, the package used to work fairly well. It has given us compilation trouble in the past, and now it looks like it stopped compiling entirely, breaking our build. The build happens inside a Docker container with all versions pinned, including NodeJS and v8-profiler itself, so it's unlikely that we can fix this on our end.

I'm thinking there must be some alternative, better maintained approach. But where is it?

(Note that restarting the server with additional flags (like --profile) is not an option, because it destroys all the evidence of the problem.)

like image 331
Thomas Avatar asked Jan 23 '20 11:01

Thomas


People also ask

How to use profiler in Node js?

The easiest way in Node. js to profile applications is by using the inbuilt profiler, which collects all the data from functions and logs it into a file. Node. js implements this by introducing the --prof flag, which communicates with the V8 profiler and then logs the data.

What is Fastify?

Fastify is a web framework highly focused on providing the best developer experience with the least overhead and a powerful plugin architecture, inspired by Hapi and Express. As far as we know, it is one of the fastest web frameworks in town.


1 Answers

I found there has been v8-profiler-next which is a successor of v8-profiler.

I hope this works for you.

like image 197
tatsuya kanemoto Avatar answered Oct 06 '22 04:10

tatsuya kanemoto