Let's consider an example where our application queries several different remote web services, presenting the retrieved data on the console.
We are not going to query real remote web services, instead we will write a very simple Node.js HTTP server that will serve as a dummy web service. Our web server doesn't really do anything significant, and therefore we will make it react to requests a bit slower than necessary, in order to simulate a real web service that has a certain workload – as you will see, this makes it easier for us to show the performance gain in our own code optimizations.
Please create a new project folder and create a file server.js with the following content:
'use strict'; var http = require('http'); var url = require('url'); var querystring = require('querystring'); http.createServer...