O'Reilly logo

Secure Your Node.js Web Application by Karl Duuna

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Manage How Your Application Uses Memory

Since the process thread is shared among all the clients, memory is also shared. You should avoid storing much information in memory per request because it can accumulate over concurrent clients and your process can die simply because it runs out of memory. In threaded servers, a thread usually has a separate memory limit that’s reached long before the whole server process runs out of memory, so only the thread gets terminated instead of the whole process. However, Node.js, being in a single thread, will kill the whole process. Let’s look at a common mistake where memory is overtaxed:

 'use strict'​;
 
 var​ express = require(​'express'​);
 var​ app = express();
 

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required