S
S
superivankorolev2016-12-06 10:27:11
JavaScript
superivankorolev, 2016-12-06 10:27:11

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',
//Какой здесь придел?

];

In my case, the service has a REST API and goods arrive from 1c, which are then pushed into the database, it is important to analyze each product separately and at the same time as much as possible.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Konstantin Kitmanov, 2016-12-06
@superivankorolev

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 question

Ask a Question

731 491 924 answers to any question