title: Limiting asynchronous calls in Node.js
body: <p>I've got a Node.js app that gets a list of file locally and uploads them to a server. This list could contain thousands of files. </p>
  
  <pre><code>for (var i = 0; i &lt; files.length; i++) {
     upload_file(files[i]);
  }
  </code></pre>
  
  <p>If I execute this with thousands of files, upload_file will get called thousands of times all at once, and most likely die (or at least struggle). In the synchronous world, we'd create a thread pool and limit it to a certain number of threads. Is there a simple way to limit how many asynchronous calls get executed at once? </p>