Concept
Starting a thousand requests or file reads at once exhausts sockets, file descriptors or the downstream service. Run them in batches, or with a limiter that keeps a fixed number in flight.
The tutor works through these with you, in conversation and code. A session ends when you have shown them, not when a video does.
A few lines that show Concurrency limits doing its job.
async function mapLimit(items, limit, fn) {
const results = new Array(items.length);
let next = 0;
async function worker() {
while (next < items.length) {
const i = next++;
results[i] = await fn(items[i]);
}
}
await Promise.all(Array.from({ length: limit }, worker));
return results;
}
const pages = await mapLimit(urls, 5, fetchPage);Replacing Promise.all with a for loop of awaits to "be safe", which processes one item at a time. A limiter gives you bounded parallelism instead of none.
Your roadmap puts these before Concurrency limits, unless you already know them.
Once a session shows you understand Concurrency limits, it comes back for review. Each review takes a minute and tells the memory model how well you still know it.