Node.js Performance Tips

We’ve gathered up the best of our weekly Node.js performance tips from the StrongLoop blog for easy reference. Have a look!

Event loop monitoring

In this week’s post we’ll look at the basics of how an event loop works and how it can cause performance issues when it goes into blocking mode. We will also discuss some tools to triage blocked event loops.

Read more…

Scaling with proxies and clusters

In this week’s blog we look at how to scale Node.js applications using a various techniques including proxy-based and application-level scaling using a combination of nginx, Apache and various clustering modules including PM2 and Strong Cluster.

Read more…

CPU profiling

Node applications are designed to maximize throughput and efficiency, using non-blocking I/O and asynchronous events. Node apps essentially run single-threaded, even though file and network events could leverage multiple threads. This architecture thereby binds the performance of each application instance/process to one logical CPU core that the thread is attached to. So, in case of a CPU running hot, throwing additional cores into the mix and using clustering, may enable you to scale horizontally. However, it does not resolve the fundamental bottleneck. Profiling the CPU under load is the go to diagnosis technique in this scenario.

Read more…

Memory leak diagnosis

Rapid memory leaks are easy to identify and often the cause of many memory issues. Node by itself is very sensitive to errors and exceptions and will crash due to out of memory exceptions. Slow leaks are the most difficult to find and often require profiling over long periods of time to properly identify. In this weeks blog we look at different leak patterns and how a good diagnosis can lead us to find the root cause of a potentially troublesome production problem.

Read more…

Heap profiling

Node runs it’s applications on Google’s V8 JavaScript engine, which uses a heap structure similar to JVM and most other languages. And like most other languages there exists many common pitfalls that can lead to poor performance brought on by memory leaks. Thus, managing the heap is vital to maintaining optimal performance and efficiency for your applications. In this week’s post we look at how to make the most of the heap profiler.

Read more…

Garbage collection

In this week’s post we’ll dive into the fundamentals of garbage collection (GC) in V8 and how it holds the “keys to the kingdom” in the optimization of Node applications. We will also look at some tools to triage GC and memory management issues in V8.

Read more…