title: Javascript - how to control how many promises access network in parallel
body: <p>in my application, I have and array of promises that access network in parallel, but some times, when my app is running full speed, my network  slows down, due to many promises accessing network, I would like to know how I could control how many access network in parallel.
  This is a sample of code:</p>
  
  <pre><code>var ids = {1: 1, 2: 2, 3: 3, 4: 4, 5: 5, 6: 6, 6: 56, 7: 7, 8: 8, 5:6 }; // this is random 
  Promise.all( Object.keys(ids).map(function(dp){
    return new Promise(function(resolve, reject){
  
         http.post({url: addr, form: { data: dp }}, function(err, res, body){
          if (err){
              reject(err)
          }            
          resolve(body.xx);
        });
  
    });
  })).then(function(data){
         http.post({url: hostAddress, form: { data: data.x }}, function(err, res, body){
          ......
          resolve(body.xx);
        });    
  });
    });
  }))
  </code></pre>
  
  <p>There are a lot of networking. I would be great I could allow only 2 or 3 at the same time. Thanks for your help.</p>