Parallel Execution Using Async/Await and Promise.all()

Learn about parallel execution using async/await.

There are mainly two ways to run a set of tasks in parallel using async/await; one purely uses the await expression and the other relies on the Promise.all() function. They’re both very simple to implement; however, be advised that the method relying on Promise.all() is the recommended (and optimal) one to use.

Web spider using async/await and Promise.all()

Let’s see an example of both. Let’s consider the spiderLinks() function of our web spider. If we wanted to use only the await expression to implement an unlimited parallel asynchronous execution flow, we would do it with some code like the following:

Get hands-on with 1200+ tech skills courses.