Parallel Execution: Web Spider Version 3
Learn about the parallel execution of a set of asynchronous tasks using web spider version 3.
We'll cover the following...
There are some situations where the order of execution of a set of asynchronous tasks is not important, and all we want is to be notified when all those running tasks are completed. Such situations are better handled using a parallel execution flow, as shown in the figure below:
Even though Node.js follows a single-threaded approach, we can still achieve concurrency, thanks to the non-blocking nature of Node.js. In fact, the word parallel is used improperly in this case because it doesn’t mean that the tasks run simultaneously, but rather that their execution is carried out by an underlying, non-blocking API and interleaved by the event loop.
As we know, a task gives control back to the event loop when it requests a new asynchronous operation, allowing the event loop to execute another task. The proper word to use for this kind of flow is concurrency, but we’ll still use ...