I have a simple express 3.2 app that returns a 200 when posted to. I watch the memory RSS of the node (v0.10.5) process and every request increases the memory by 4kb or so.
The server code is quite simple:
var express = require('express');
var app = module.exports = express();
app.set('port', process.env.PORT || 3000);
app.use(express.favicon());
app.use(express.bodyParser());
require('./apps/events/index')(app);
app.listen(app.get('port'), function(){
console.log("Express server starting...");
});
and the corresponding controller code is :
// ./apps/events/index.js
var events = function(app) {
app.post('/events', function(req, res) {
res.writeHead(200);
res.end();
});
}
module.exports = events;
Is there something in my code that is causing this? Is this normal (hopefully not). Or am I measuring the wrong thing? I put a version of this script into production and the node process started at 16mb memory use, and after some load testing (20,000 hits) it increased to 32mb.
Keep profiling your server. You will probably find that memory usage levels off over time. Try 200,000 requests and see if things change
Also if there is memory available the operating system will try to use it. 32mb of ram is not enough to be concerned about.
This talk is worth watching. It is about python but the concepts are the same for node.js
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With