parallel_machine
![NPM version](http://img.shields.io/npm/v/parallel_machine.svg)
Javascript library for distributing async computation based on a distribution key.
Installation
npm install parallel_machine
Example
Scenario: We want to run multiple expensive database migrations across many tables in a large database cluster.
We try to distribute the load across all the database hosts via parallel_machine. This will both minimize the operation time as we'll be doing multiple operations at once whilst avoiding overloading a single host.
var parallel_machine = require("parallel_machine");
tables = [
{databaseHost: 'a', tableName: 'foo'}
]
function expensiveDatabaseMigration(task, callback) {
}
var options = {
taskDescriptor: (task) => task.databaseHost,
executor: expensiveDatabaseMigration,
keyParallelism: 5,
overallParallelism: 30
}
parallel_machine(tables, options, (err) => {
console.log('Tasks complete.', err);
});