1.0.6 • Published 9 years ago

sticky-load-balancer v1.0.6

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

sticky-load-balancer

Module for nodejs v4+ to create a loadbalancer with a sticky-strategie.

custom sticky strategies

Create own sticky strategies to distribute requests depending on the incoming data. ( cookies, headers, GET, body.. )

Dependencies

This module needs the npm-module 'farmhash'. To use this you need a python compiler. For Linux you can run the following commands to install it. With windows you are screwed.

apt-get install build-essential
apt-get install python
apt-get install g++
npm install node-gyp -g

Installation

npm install sticky-load-balancer --save

Visit

npm | github

Example Code

StickyLoadBalancer = require('sticky-load-balancer');

//set loggin to active
StickyLoadBalancer.setLogging(true);

//create new balancer
var balancer = new StickyLoadBalancer('127.0.0.1', 5555);

/**
 * this must be unique if you chain multiple balancers together.
 * @default Math.random()^5
 */
balancer.setIdentifier('foooooobar');

/**
 * define which parts of a request should be take to create your sticky strategie.
 */
balancer.setStickyStrategy([
    'url',
    'body.foo',
    'body.foobar',
    'headers.user-agent',
    'cookie.foo'
]);

//start the balancer
balancer.start();

Example Code to remotely add one node to the balancer

StickyLoadBalancer = require('sticky-load-balancer');
/**
 * tell the balancer that this node exists
 */
StickyLoadBalancer.tellBalancer(
    {
        //stats of the balancer
        ip: '127.0.0.1',
        port: 5555,
        identifier: 'foooooobar'
    },
    {
        //stats of the node
        ip: '127.0.0.1',
        port: 80,
        balance: 6
    }
);
1.0.6

9 years ago

1.0.5

10 years ago

1.0.4

10 years ago

1.0.3

10 years ago

1.0.2

10 years ago

1.0.1

10 years ago

1.0.0

10 years ago

0.0.5

10 years ago

0.0.4

10 years ago

0.0.3

10 years ago

0.0.2

10 years ago