Answer the question
In order to leave comments, you need to log in
Multithreading solution for node.js?
Hello. There is a need to work in N number of simultaneous threads, which are independent of each other. The structure is this: each thread makes a request and writes to the database, and this happens in a cycle until the thread runs out of cycle.
Only the creation of a number of workers through cluster N comes to mind, but there will be many more workers than the core of the processor.
Maybe there are some other solutions (example) or some suggestions according to my idea?
If possible, please provide an example.
Answer the question
In order to leave comments, you need to log in
It is possible to make and in 1 flow through queues and asynchrony. We have N arrays A1.. AN, we start for them in a loop for each of our eachSeries, something like this:
async.eachSeries(A1, function(item, cb) {
// сюда приходит item, когда с ним покончено, то делаем cb()
}, function() {
// все готово
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question