I built a script in Node to loop over 10k+ records and make HTTP requests per record. This works great as long as i set the maxSockets
to 20. However, the script starts slowing down around 2500 and then eventually just stops. No errors. Memory and CPU usage don't spike in Activity Monitor. I rewrote the same script in Python and it works fine but is much slower. Any ideas?
Here is the basic idea of the script:
var fs = require('fs'),
https = require('https');
input = fs.readFileSync('./csv.csv'),
parse = require('csv-parse');
https.globalAgent.maxSockets = 20;
parse(input, {}, (e, o) => {
o.forEach((l, i) => {
var req = https.request({
host: 'some.host.com',
path: `/some/path/${l[4]}`,
port: 443,
method: 'GET'
}, (res) => {
if(res.statusCode === 200) {
fs.appendFile('./results.csv', `${l}\n`);
}
});
req.end();
});
});