The async module offers several other mechanisms for managing the control flow of our code. These are interesting even if our concern isn't performance optimization. Let's investigate them.
For these cases, let's remove the artificial slowness from the API server by removing the setTimeout operation, making the server respond immediately:
'use strict'; var http = require('http'); var url = require('url'); var querystring = require('querystring'); http.createServer(function(request, response) { var pathname = url.parse(request.url).pathname; var query = url.parse(request.url).query; var id = querystring.parse(query)['id']; var result = { 'pathname': pathname, 'id': id, 'value': Math.floor(Math.random() * 100) }; response.writeHead(200, {"Content-Type...