‚ÄúProfiling‚ÄĚ as in stereotyping is not a good practice.¬† However, when it comes to node.js it is a very good practice to ‚Äúprofile‚ÄĚ your code.¬† Using Profiling techniques it is possible to generate views of CPU and memory utilization for your applications, detect memory leaks and/or CPU issues and then take action to optimize your code.
There are several tools to help you profile your node.js code.¬† The purpose of this blog is to help gather pointers to the tools together into a single place.
Where to begin?¬† How about with the profiler that is built into Node itself!¬† Node.js provides a built in capability to find CPU and memory
StrongLoop Arc and slc are no longer under active development, and will soon be deprecated. Arc’s features are being included in the IBM API Connect Developer Toolkit which is what should be used for these functions.¬† However there are a few StrongLoop urls that provide good information on profiling that we have included:
- https://docs.strongloop.com/display/SLC/Profiling+with+Arc ‚Äď provides an overview of profiling with Arc
- https://strongloop.com/strongblog/how-to-heap-snapshots/ – provides instructions for instrumenting your app with heapdump, techniques for collecting snapshots, and resources for snapshot analysis
- https://strongloop.com/node-js/node-js-performance-tips/ – an excellent collection of node.js performance tips
WebStorm is a lightweight yet powerful Integrated Development Environment for client-side and server-side development with Node.js that also provides a GUI profiler tool (https://www.jetbrains.com/help/webstorm/2016.2/v8-cpu-and-memory-profiling.html).¬† The GUI tool provides an easy to use interface providing both CPU and memory profiling capability.
Richard Chamberlain (IBM) provided a blog ‚ÄúNodeReport ‚Äď first failure data capture for Node.js‚ÄĚ describing how to implement first failure data capture (FFDC) using the NodeReport npm module.¬† The blog describes how to install and configure the NodeReport capability.¬† With FFDC debugging is always on, but has minimal impact to performance.¬† This allows the capturing of sufficient data on the first instance of failure rather than post-processing error conditions which may be difficult to recreate.
Finally, IBM supplies a Health center that can assist with profiling node.js.¬† The health center was originally provided for Java and has been extended to support node as well.¬† Stewart Addison wrote a blog ‚ÄúMonitoring your Node.js application with the (free) IBM Health Center‚ÄĚ describing how to install and execute the health center capabilities to profile your node.js application.
IBM API Connect is IBM‚Äôs complete foundation to Create, Run, Manage, and Secure APIs.¬† You can find more information about IBM API Connect at the API Connect website.¬† And you can also experience a trial version of API Connect.
If you have questions, please let me know.¬† Connect with me through comments here or via twitter @cyberfeng to continue the discussion.