An HAProxy clone written in node for more flexibility and embedding into a node process.

Poised - HTTP Load Balancer in Node

Why not HAProxy?

Well, if you can get away with HAProxy, you should! If you need more... read on.

With poised, you can script load balancing logic as opposed to declaritively configure it.
You can also define when to add and evict servers.

Poised can run standalone (see examples), but it can also be integrated into node. If you are running node in your stack, why not just resolve your servers within your actual process instead of going through another proxy.

Quick Start

Here is an example script load balancing 2 http servers:

var poised = require('poised');
var http   = poised.http();
var front = http.front('main-www');
var back = front.back('main-www');
back.server('server1', '');
back.server('server2', '');

Just save this in a file and run "node ".


This defines the protocol (only http for now) scope.

var poised = require('poised');
var http = poised.http();

This defines the front end of the proxy. You should have one front for each incomming port you are listening to.

var www = http.front('www');

This defines backends to route to. Here, you can define which cluster of servers you want to route to.

var staticBack = www.back('static', { host: /^static/ });
var wwwBack    = www.back('www');
wwwBack.balance({ algorithm: 'weighted' });
staticBack.balance({ algorithm: 'resource' });

This introduces a server if to a back cluster.

var server1 = wwwBack.server('server1', 'http://localhost:3000');
var server2 = wwwBack.server('server1', 'http://localhost:3001');
var server3 = wwwBack.backup('server3', 'http://localhost:3001');

Load balancing algorithms

Advanced Usage

  algorithm: 'resource', 
  key: function (req) { return req.headers['servername'] }
function shouldIntroduce(back, name, url) {
  var server = back.server(name, url);
  setTimeout(function () { 
    if (server.averageResponseTime() > 200) back.evict(name);
  }, 60000);


Jeff Su