0.1.0 • Published 9 years ago

async-cluster v0.1.0

Weekly downloads
2
License
MIT
Repository
github
Last release
9 years ago

async-cluster

A single instance of Node.js runs in a single thread. To take advantage of multi-core systems users can use Cluster.

This module uses Cluster to perform iterations using n cores in parallel. Which can drastically decrease the time spent to perform high intensity CPU operations.

Benchmark

Benchmark using time to measure the amount of seconds spent to finish the operation.

Performed using a MacBook Pro with Intel i7 2.5 GHz @ 8 Cores.

files writtensingleCore.jsmultiCore.js
1006.5691.372
50032.6006.442
100065.8412.653
2000133.9026.217
4000268.9256.003

Install

To install the most recent release from npm, run:

npm install async-cluster

Example

Master

var ac = require('async-cluster');
var cpuCores = require('os').cpus().length;
var worker = __dirname+'/worker';

ac.eachCore(list, cpuCores, worker, callback);

Worker

module.exports = function(item, callback) {
  ...
  callback();
};
0.1.0

9 years ago