Operations | Monitoring | ITSM | DevOps | Cloud

Avoiding Memory Leaks in NodeJS: Best Practices for Performance

Memory leaks are something every developer has to eventually face. They are common in most languages, even if the language automatically manages memory for you. Memory leaks can result in problems such as application slowdowns, crashes, high latency, and so on. In this blog post, we will look at what memory leaks are and how you can avoid them in your NodeJS application. Though this is more focused on NodeJS, it should generally apply to JavaScript and TypeScript as well.

An Exploration of Runtime Metrics: Node's Event Loop

What Are Runtime Metrics? Runtime metrics can help us understand how an application is performing. SolarWinds® AppOptics™, a SaaS-based, full-stack infrastructure and application monitoring tool, now reports four categories of runtime metrics: CPU, memory, garbage collection times, and event loop times. Each metric category provides a view into how resources are used by an application.

NodeJS Instrumentation - Adding Analyzed Spans for Improved Data Analytics | Datadog Tips & Tricks

In part 4 of this 4 part series, you’ll learn how to add Analyzed Spans to your traces to open up even more data search and aggregation capabilities via App Analytics. In this video, we will walk you through how you can turn any span into an Analyzed Span. Analyzed Spans function like the root spans of a trace, allowing us to turn the tags embedded in them into facets for advanced data aggregation and searching in App Analytics. You can check out how to add tags to spans—and how to utilize them in App Analytics—in our first video of the series here (link to the first video).

NodeJS Instrumentation - Adding Custom Tags to Spans | Datadog Tips & Tricks

In part 1 of this 4 part series, you’ll learn how to use manual instrumentation to add additional detail to traces. We’ll add new tags, or attributes, to the spans generated by our NodeJS application, allowing for more insightful data visualizations in App Analytics.

NodeJS Instrumentation - Creating Custom Spans for Method-Level Visibility | Datadog Tips & Tricks

In part 2 of this 4 part series, you’ll learn how to instrument your NodeJS application to capture custom method-level spans, allowing visibility into how specific methods behave in your application. Flame graphs allow for deep insight into the performance of your code. During instrumentation, we can capture custom spans for deeper layers of visibility in the resulting flame graphs. In this video, we use instrumentation to capture a method-level span, allowing us to see the performance of that specific method in our flame graphs in the Datadog UI.

Top metrics to look out for while monitoring Node.js applications

Applications built on the Node.js platform, an event-driven I/O server-side JavaScript environment based on Google Chrome’s V8 engine, are known as Node.js applications. Since both the server-side and the client-side are written in JavaScript, Node.js facilitates easier and faster implementation of codes, and processes requests quickly and simultaneously; this is greatly beneficial for building real-time applications, especially chat and streaming applications.

Smooth mocking with the Elasticsearch Node.js client

A classic problem that every backend developer has faced during their work is testing an application that uses a database. A perfectly valid solution is to use the real database for testing your application, but you would be doing an integration test, while you want a unit test. There are many ways to solve this problem. You could create the database with docker, or use an in-memory compatible one, but if you are writing unit tests that can be easily parallelized this will become quite uncomfortable.

A complete guide to getting started with the Node debugger

Diagnosing and finding the root cause of issues is a crucial skill in software development. Software engineers spend the majority of their time reading and understanding existing code. Because of this, knowing how to debug your applications with proficiency will save you time and make you more effective.