1.0.6 • Published 7 years ago

load-balancer v1.0.6

Weekly downloads
7
License
MIT
Repository
github
Last release
7 years ago

load-balancer

npm version


Introduction

Load-balancer is a task manager for nodejs tasks.

If you have lots of independent tasks, and wish them to be done as soon as possible, you can try this tool!

Load-balancer will take full usage of CPUs.

npm.io

  • Create workers.
  • Master send tasks to every worker.
  • When a worker finishes it's task, will receive a new one from master.
  • If no more tasks remain, workers will be killed.

Installation

npm i load-balancer --save

Usage

master.js

var Balancer = require('load-balancer');
...
// create a master
var master = new Balancer.Master('Master A');
// master send jobs to workers
master.send('worker.js', context, jobDetails, function(results) {
    // all jobs done here
});

worker.js

var Balancer = require('load-balancer');
...
// create a worker
var worker = new Balancer.Worker('Worker A');
// worker receive job from master
worker.receive(function(master, context, jobDetail, callback) {
    // deal with jobDetail
    callback(result);
});

Examples

You can find more examples here.

Benchmarking

npm test

See minify assets case:

CaseDuration(ms)
1 Process(Normal)21947
Multi-Processes(Auto)12840

Intel® Core™ i5-6200U CPU @ 2.30GHz × 4
Ubuntu 16.04 64bit

1.0.6

7 years ago

1.0.5

8 years ago

1.0.4

8 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago