load-balancer
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.
- 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 = ;...// create a mastervar master = 'Master A';// master send jobs to workersmaster;
worker.js
var Balancer = ;...// create a workervar worker = 'Worker A';// worker receive job from masterworker;
Examples
You can find more examples here.
Benchmarking
npm test
See minify assets
case:
Case | Duration(ms) |
---|---|
1 Process(Normal) | 21947 |
Multi-Processes(Auto) | 12840 |
Intel® Core™ i5-6200U CPU @ 2.30GHz × 4
Ubuntu 16.04 64bit