Lesson 24 — Concurrency limiter
Only N at a time
Firing 100 requests at once can overload a server or hit a rate limit. A concurrency limiter runs async tasks with at most N in progress: start N workers, and each worker keeps taking the next task until none are left. Results are stored by index so they come back in the original order.
// 2 workers, 3 tasks: worker A takes task 0, worker B takes task 1,
// whoever finishes first takes task 2.
Why it matters: this protects APIs and memory in scrapers, uploads and batch jobs — a real interview and production pattern.
Finish limit(): store each result, start n workers, and wait for them. Expect finished 2, finished 3, finished 1, then [ 1, 2, 3 ].
Run your code — when the output matches the task, you will see a green check. Then mark the lesson complete.
A quick 3-question quiz on this lesson — instant feedback.
Ready for more? Optional paid resources that pick up where this lesson leaves off.
Some links on this page are affiliate links: we may earn a commission at no extra cost to you. As an Amazon Associate I earn from qualifying purchases.
Project-based JavaScript Intermediate courses if you want a structured paid path after the free lessons. Wait for a sale — prices drop often.
Browse on Udemy →Search Amazon for JavaScript Intermediate books — check the publication year so the examples match current versions.
Search Amazon →