Executing expensive asynchronous background tasks in parallel

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: ...

Get The Node Craftsman Book now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.