Skip to main content

Posts

Showing posts with the label jmeter

Node.js and reckless console.log() statements

I've seen code that over uses, nah rather abuses the logger. Many times teams use it in the wrong way or sometimes over use it and then struggle to improve performance. This simple test will show the effect.

From the synopsis of Node.js doc, this is my server code:

var http = require('http');
http.createServer(function (request, response) {
    response.writeHead(200, {'Content-Type': 'text/plain'});
    response.end('Hello World\n');
}).listen(8124);
console.log('Server running at http://127.0.0.1:8124/');

Now I use JMeter to test the performance. I fire a 1000 HTTP requests within a time frame of 2s, with a wait of 1ms duration in between each new request. In my environment the median response time was 2ms for each request.

Now I add a single console log statement for the callback function in the above server code.

var http = require('http');
http.createServer(function (request, response) {
    response.writeHead(200, {'Content-Type': …