Examining Observability in Node.js

Rate this content
Bookmark

Imagine your productivity and confidence developing web apps without chrome dev tools. Many do exactly that with Node.js.

It is important to observe and learn what’s happening in your app to stay competitive and create the most performant and efficient Node.js applications, following the best practices.

In this talk, we will explore useful tools to examine your Node.js applications and how observability will speed up development, produce better code while improving reliability and uptime. Don’t miss it!

This talk has been presented at Node Congress 2021, check out the latest edition of this JavaScript Conference.

FAQ

Observability in Node.js is the measure of how well internal states of a system can be inferred from its external outputs. It allows developers to understand what is happening inside the system by observing its outputs without needing to modify the code.

Observability is crucial due to the increasing complexity of software and infrastructure, like microservices and containers. It provides essential tools to understand, find, and fix issues within the software, enhancing the ability to maintain system health without additional coding.

Node.js internals for observability include performance hooks, trace events, and heap snapshots. These tools help developers monitor and understand the performance and health of Node.js applications by providing insights into the system's operations.

External tools like New Relic, Datadog, and Instana provide additional layers of monitoring and analysis for Node.js applications. They offer features such as detailed performance metrics, error rates, and request monitoring, which help in optimizing application performance.

Observability involves exposing the internal states of a system for external view, allowing for a deeper understanding of its operations. Monitoring, on the other hand, focuses on collecting and displaying information based on the data exposed by observability tools.

Performance hooks in Node.js are used to collect performance metrics from the Node.js instance. They are useful for identifying performance bottlenecks and ensuring that performance considerations are integrated during the development process to prevent issues in production.

Heap snapshots capture the memory usage details of Node.js applications at a specific moment. They are crucial for identifying memory leaks and understanding memory allocation, which can help in optimizing memory usage and enhancing application performance.

Observability tools should minimize overhead to prevent slowing down the application. High overhead can negate the benefits of observability by affecting application performance, thus it's crucial to choose tools that offer detailed insights with minimal performance impact.

Lizz Parody
Lizz Parody
22 min
24 Jun, 2021

Comments

Sign in or register to post your comment.

Video Summary and Transcription

Today's Talk explores the concept of observability in Node.js, emphasizing the importance of understanding what's happening inside a system without needing to ship new code. The Talk covers various observability tools and techniques, including performance measurement and tracing, HeapSnapshot and Chrome DevTools, the BA Inspector, and external tools like nSolid. nSolid is highlighted as an enhanced observability tool specifically built for Node.js, offering low-input performance insights and greater security for mission-critical applications.

1. Introduction to Observability in Node.js

Short description:

Today, I will be talking about examining observability in Node.js. Observability is a term from control theory. In several products and services, observability means you can answer any questions about what's happening on the inside of the system by observing or by asking questions from the outside of the system without needing to ship new code to answer questions. Because system complexity is outposing our ability to predict what it's going to break. There's a lot of useful tools that come to rescue.

Hello, all. Today, I will be talking about examining observability in Node.js. Hi, my name is Liz Paradis, I'm the head of Developers Relations at Nodesters, and I am from the beautiful country of Colombia.

This is the agenda for today. First, we're going to talk about what is observability, then why observability is important, how we can use Node.js internals for observability, including performance hooks, trace events, heap snapshots, BA native module. And then we will look at some external tools, benchmarks, and conclusions at the end.

So, let's begin by understanding what observability is and why it's important. Observability is a term from control theory. A simple definition could be it's the measure of how well internal states of a system can be inferred by the knowledge of its external outputs. In other words, we see the results, or the output, and we can know what's happening on the inside. Let's take, for example, bananas and avocados. In Colombia, we have a lot of bananas and avocados. It's amazing. And just from looking at the outside, we can know how it is on the inside, if they're ripped, or if they're not ready for consumption yet. In several products and services, observability means you can answer any questions about what's happening on the inside of the system by observing or by asking questions from the outside of the system without needing to ship new code to answer questions. And that's very important. We shouldn't need to write new code to observe what's happening on one of our systems. Because system complexity is outposing our ability to predict what it's going to break. There's a lot of useful tools that come to rescue.

2. Importance of Observability and Choosing Tools

Short description:

Talking about system complexity, software is becoming exponentially more complex. The number of products and tools are multiplying. With environments as complex as we see today, simply monitoring from problems is not enough. Observability gives you the instrumentation you need to understand what's happening in your software and fix it. Observing is exposing the internal state to be viewed externally, and monitoring is collecting and displaying the information that has been exposed. To solve complex nodejs problems, it's necessary to have an observability tool. In choosing an observability tool, we're going to focus on nodejs internals and external tools like performance hooks.

Talking about system complexity, software is becoming exponentially more complex. In infrastructure, we're seeing things such as microservices, containers, Docker, Kubernetes, and others that decompose monoliths into microservices, which are great for products but can be hard on humans. The number of products and tools are also multiplying. There are countless platforms and tools for empowering people to have better observability and control over their code. Great for users. But it's very hard to choose which one is the best one.

Now that you know what observability is, you will be wondering why it's important and why you should care. With environments as complex as we see today, simply monitoring from problems is not enough to recognize, find, and fix a number of issues that arise. Sometimes the new issues are known or not, which means that you don't know the problem, and even worse, you don't know how to find it. So without tools to observe the environment, it's almost impossible to fix that problem. This is why observability is important. It gives you the instrumentation you need to understand what's happening in your software and fix it. A good observability tool helps you find what and where the problem is. It doesn't add overhead to your app. We don't want our app to slow down. Quite the opposite. It also has enhanced security, has flexible integration, and doesn't need to modify your code. And it's also very important to differentiate between observing and monitoring. Observing is exposing the internal state to be viewed externally, and monitoring is collecting and displaying the information that has been exposed, and usually involves writing automation tools around that.

If you want to solve the most complex nodejs problems such as memory leaks, or performance issues, or even just to follow the best practice to keep your code healthy, it's necessary to have an observability tool. The next step will be choosing an observability tool that are best for our needs. So in choosing an observability tool, we're going to focus first on nodejs internals, and then we're going to check some external tools. In nodejs internals for observability, first we're going to talk about performance hooks. This is particularly helpful for checking on performance. It's an object that can be used to collect performance metric from the current nodejs instance. Performance monitoring is not something you should start considering once you start seeing problems. Instead, it should be part of your development process in order to detect possible problems before they are visible in production. Because of the asynchronous nature of nodes, code profiling with regular tools can be very challenging. Especially because part of the time spent could be outside of your own code and inside of the event loop itself. This is why it's important to use even internal nodejs tools like performance hook or external tools as we're going to discuss later.