How to fix AWS s3.getObject() delaying at 30 simultaneously downloads

Keywords´╝Ü node.js amazon-s3 aws-sdk digital-ocean

Question: 

When I download 30 x files from Digital Ocean S3 in parallell it seems to halt/delay at the last 1 or 2 files. The files are about 5 mb each.

This happened since switching to the official AWS library for Node JS. Before I was using the 's3' library and it worked fine.

If I do 25 parallell downloads it works fine.

Running Node v. 12.3.1


  // Params
  var params = {
    Bucket: "vmh-v3",
    Key: key
  }

  // WriteStream
  var fileStream = fs.createWriteStream(output)

  // Request
  s3.getObject(params)
  .createReadStream()
  .pipe(fileStream)
  .on('error', error => {
    return cb('Unable to download file ' + key)
  })

  // Finished
  .on('finish', function() {
    cb(null, output)
  })
}

Answers: