JavaScript · Senior · Question 23 of 75

How do you limit the number of concurrent requests when loading 100 URLs?

Explanation

Promise.all starts everything at once and has no limit (the browser's connection limit concerns the network, not memory or the server). A pool of N async functions pulling tasks from a queue keeps exactly N requests in flight. Ready-made implementations: p-limit and similar.

Further reading

Problem with a question

JavaScript · Senior · question 23

Test yourself

Take the JavaScript · Senior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz