title: Run 1000 requests so that only 10 runs at a time
body: <p>With node.js I want to <code>http.get</code> a number of remote urls in a way that only 10 (or n) runs at a time.</p>
  
  <p>I also want to retry a request if an exception occures locally (m times), but when the status code returns an error (5XX, 4XX, etc) the request counts as valid.</p>
  
  <p>This is really hard for me to wrap my head around.</p>
  
  <p>Problems:</p>
  
  <ol>
  <li>Cannot try-catch http.get as it is async.</li>
  <li>Need a way to retry a request on failure.</li>
  <li>I need some kind of semaphore that keeps track of the currently active request count.</li>
  <li>When all requests finished I want to get the list of all request urls and response status codes in a list which I want to sort/group/manipulate, so I need to wait for all requests to finish.</li>
  </ol>
  
  <p>Seems like for every async problem using promises are recommended, but I end up nesting too many promises and it quickly becomes uncypherable.</p>