I have a function in my Node projects which I want to run parallel, i.e, as multiple instances, in the multi-core systems
The function's code is kind of like this:
try {
const doc = collection_name.findOne({ '_id': id });
if (doc) {
// process the doc
process(doc);
}
} catch (err) {
collection_name.update( // update some fields);
}
Now, what I want is to create N instances of this method, where N is the number of core available in the system. I know that Node.js's module: Cluster and Child Process can be used here but I'm not exactly sure how I can implement them.
via myke_11j
No comments:
Post a Comment