Answer the question
In order to leave comments, you need to log in
How many concurrent Promises can you make in Node.js?
For example like this:
function httpGet(url) {
return new Promise(function(resolve, reject) {
resolve(url);
}
Promise.all( urls.map(httpGet) ).then(results => {
console.log(results);
});
let urls = [
'/article/promise/user.json',
'/article/promise/guest.json',
//Какой здесь придел?
];
Answer the question
In order to leave comments, you need to log in
You need to understand that nodejs is a single-threaded thing. If you really need direct simultaneous processing, then you need to parallelize it to all cores using cluster .
It is unlikely that you will run into a limit on the number of promises (if there is one at all). It is more likely that much earlier you will run into the number of open network connections, the performance of the server, where you are requesting data from, and so on.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question