Simple concurrency limiter for batch operations

14611
0

Unbounded Promise.all is a great way to overload your DB (or a third-party API). I use a small concurrency limiter so I can process batches efficiently while keeping backpressure. This is especially useful for migrations, backfills, and webhook replays where you might touch thousands of records. I like making concurrency configurable via env so I can tune it per environment without code changes. The main idea is being intentional about resource usage: your service has a finite DB pool and a finite CPU budget. A limiter keeps throughput high without turning background tasks into accidental stress tests.