Book Image

Building Scalable Apps with Redis and Node.js

By : Joshua Johanan
Book Image

Building Scalable Apps with Redis and Node.js

By: Joshua Johanan

Overview of this book

Table of Contents (17 chapters)
Building Scalable Apps with Redis and Node.js
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

CPU profiling our application


Our next troubleshooting method is going to be CPU profiling. This will let us know what functions are the most CPU intensive. For this, we will use webkit-devtools-agent. The setup for this tool is a little more difficult than the last.

The first thing we need to do is add a reference to the module. Open up app.js and add this line to the top, as highlighted in the following code:

var agent = require('webkit-devtools-agent');
var express = require('express');
var app = express();

Technically, this is all we need to add to our code. If this was a production codebase, we could check whether we were in development or not and load this module. We can start the node at this time.

The next step is to send a USR2 signal to the process-running node. Signals are a way to notify a process. A common signal is TERM that tells the process to start shutting down and to terminate. USR2 is a user-defined signal. This means that developers can decide what to do when the signal...