I create 10000 get requests to example.com, and send them concurrently by using promise.
It take more than 1 minute.
If create 1 get request, it take only 500 ms.
Why do too many requests take so long time regardless of sending them concurrently?
I think 10000 requests should take 500ms as same as 1 request if it's completely concurrent.
It's not the cpu or memory problem because I tried multithread and memory increase, but the time is not changed. Even 10000 different urls, it's not changed. So this is client matter I guess.
Is there any other root cause?
How can I improve the time?
My code here.
const got = require("got");
console.time('total');
const urlList = Array(10000).fill("https://example.com");
const pList = urlList.map(function(url) {
return got(url, {timeout: {request: 60000, }, retry: {limit: 0}}).catch((e) => {
console.log(e);
return null;
});
});
Promise.all(pList).then((result) => {
console.timeEnd('total');
}).catch((e) => {
console.log('error: ' + e);
});
Thank you in advance!