npm install multi-requestA request.js (https://www.npmjs.com/package/request) wrapper that support multi process request.
$ npm install multi-request
Just require the module like this:var MRequest = require("multi-request")
javascript
MRequest("http://google.com",function(err,response,body){
// do something
})
`
$3
`javascript
MRequest("http://google.com").then(function(result){
var response = result.response;
var body = result.body;
}).catch(console.error)
`Manage Worker usage
By default,
multi-request will spawn maximum cpuLoad * cpuCount. You can change cpuLoad by calling .changeCpuLoad(num). For example :`javascript
MRequest.changeCpuLoad(3)
`will set maximum Worker count to
3 * cpuCount. Please be alerted that currently multi-request only support expanding maximum worker count. If you try to call changeCpuLoad with parameter less than any subsequent call, it will not resulted in decreased running Worker. This feature is planned for future release.How does it works?
multi-request initially spawn 1 Worker. As the request grows, multi-request will try spawn` new Worker until maximum worker count is reached.https://github.com/aerios/multi-request