O'Reilly logo

The Node Craftsman Book by Manuel Kiessling

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required