Parallel Execution

Learn parallel execution with web spider version 3.

We'll cover the following

Another execution flow that becomes trivial with promises is the parallel execution flow. In fact, all that we need to do is use the built-in Promise.all() method. This helper function creates another Promise that fulfills only when all the promises received as input are fulfilled. If there’s no causal relationship between those promises (for example, they’re not part of the same chain of promises), then they’ll be executed in parallel.

Web spider v3

To demonstrate this, let’s consider version 3 of our web spider application, which downloads all the links of a page in parallel. Let’s just update the spiderLinks() function again to implement a parallel execution flow using promises:

Get hands-on with 1400+ tech skills courses.