i have a problem with high cpu usage when streaming file from Mongodb Gridfs to file system. I'm currently using gridfs-stream node.js module and the code is as follows:
//Main server file
app.get('/download/:name', crud.download)
//crud.js file
exports.download = function(req, res){
var file = req.params.name
var readstream = gfs.createReadStream(file);
readstream.pipe(res);
}
On smaller files (~100mb and more) cpu usage is pretty low while on bigger files (~1GB and more) cpu goes to 90-100% and stays like that, slowing download speed significantly, and sometimes even blocking whole download. Also, is there a better way for handling downloads to file system from Gridfs? Would like to hear some opinions. Thanks.