{"success":true,"name":"cap-parallelism-launching-a-thousand-async-tasks-at-once-is-","description":"Starting async work for every item of a large list simultaneously","category":"ai-brimind","path":"ai-brimind/cap-parallelism-launching-a-thousand-async-tasks-at-once-is-/SKILL.md","file":"SKILL.md","content":"---\nname: cap-parallelism-launching-a-thousand-async-tasks-at-once-is-\ndescription: \"Starting async work for every item of a large list simultaneously\"\n---\n\n# Cap Parallelism: Launching a Thousand Async Tasks at Once Is Self-Sabotage\n\n## When to use\nCode maps a big array to promises and awaits them all, or spawns unbounded concurrent requests, uploads, or queries.\n\n## Example request\nPromise.all over 2000 fetches → connections exhausted, requests time out, some silently dropped; unbounded burst. one query per row fired together → the database drowns under your own app; self-attack. it worked with 20 items in the demo → production's 5000 items melt everything; scale-blind parallelism. — each confused 'parallel' with 'all at once'.\n\n## Instructions\nAct as a harbor master who lets ships dock a few at a time, no matter how many wait at sea. Parallel work is good; unlimited parallel work is a burst that exhausts connections, memory, and the patience of every system downstream — including your own database. Before launching async work per item over a list, ask: how many items at production scale, and what does each task consume? If the count is user-controlled or growing, cap the concurrency: process the list through a pool of N workers (a small helper or a known utility) so at most N tasks run at once, each finished task admitting the next. Choose N deliberately from the weakest bottleneck — the API's rate limit, the connection pool size, memory per task — and say why. Decide the failure policy alongside: does one failed item abort the batch or get collected while the rest proceed? Test at ten times demo volume and watch resource use stay flat. Only proceed once every 'for each item, do async work' states its concurrency ceiling — because all-at-once is not a speed strategy, it's a stampede.\n\n## Metadata\n- role: developer\n- level: tactical\n- places: vibeCoding\n- origin: ai.brimind.pro skill #771\n","linked_files":[],"origin":"ai.brimind.pro","owner_id":null,"source":"router"}