From the course: Advanced Node.js

Unlock the full course today

Join today to access over 23,500 courses taught by industry experts.

Concurrent tasks

Concurrent tasks - Node.js Tutorial

From the course: Advanced Node.js

Concurrent tasks

“

- [Instructor] So so far we've looked at a couple of ways to execute asynchronous tasks sequentially. We also looked at a way that we can execute asynchronous task as promises in parallel. But what happens if we want to combine both sequential and parallel operations? Sometimes your promises may contain large tasks that eat a lot of resources or take a lot of time to process. Running everything at once can be too costly, but running one task at a time may take too long. A possible solution for this is to create a task queue that can run a specified number of tasks concurrently at the same time. Let's implement a promise queue that can run a specified number of promises at the same time. For this example I'm inside of our exercise files under chapter one, chapter one, less eight and within the start folder you'll see that we have the delay promise that we created that will create a promise that will delay for a specified number of seconds. So here we have a list of tasks and we're…

Contents