Monitoring the performance of a Node.js web application

Last updated 1 year ago by Vladimir De Turckheim

nodejs

Introduction

When running a web application in production, performance is important. Slow web servers provide degraded user experience and can threaten a whole company’s business.

In order to fully understand how a web application runs in production, load testing is not enough. Even if tools like ab can give measures regarding how fast a server answers under a specific load, they can’t tell you where the bottlenecks are.

In this article, we will build a tool that will monitor how much time is spent in MongoDB when a simple Node.js application answers an HTTP request.

Let’s build a user story

As a developer, I want to be able to know how much time my server spends in external services when answering an HTTP request.

For this article, let’s look at the simple Express/Mongoose application here:

https://github.com/sqreen/funAPM/blob/master/testApp/server.js.

For this application, we want to monitor the time spent in MongoDB for each HTTP request.

Also, in this article, we will only use the async/await syntax.

Read full Article