Profiling means generating CPU profiles and heap memory snapshots for an application. These can help detect memory leaks and other run-time issues.
StrongLoop tools enable you to profile both local and remote Node applications. You can:
Using the StrongLoop profiler demo app
The StrongLoop profiler demo app is a simple LoopBack application that showcases CPU and heap profiling.
The demo app includes a load generator script that makes two POST requests:
POST /documents- creates multiple instances of the document object and burns CPU. Use the CPU profiler to see the CPU usage.
POST /documents/content- increases the Document count. Use the heap profiler to see the increased object count.
Install demo app
Install the profiler demo app from GitHub:
Run the app:
Then display the application status to ensure that the application is running:
You should see something like this:
Now, run the load generator script:
You can collect CPU and heap profiling data using the
slc ctl commands and Google Chrome tools.
For example, to profile CPU consumption for worker process number one (1):
Then, after a few seconds, stop CPU profiling:
To profile heap memory consumption:
See slc ctl for more details.