socket-load-balancer
This is a load balancer that works at TCP/Unix Socket level and distributes connections across different servers.
Example:
var slb = ; var router = slbrouters; var server = slbserver;
Router
The router is the object responsible of decide to which destination forward a request.
A router can be a function:
var slb = ; var server = slbserver;
or can be an object with a manage method
var slb = ; var server = slbserver;
There are already 2 Routers available:
- RoundRobin Dispatches requests to a group of routes in a Round-Robin fashion (every request is forwarded to a different route in a circular order)
- LeastUsed Dispatches requests to a group of routes in a Least Used fashion (every request is forwarded to the route that has the lowest number of active connections)
They both have a common interface:
- addRoute( route ) adds a new route
- removeRoute( route ) removes an existing route
Timeout
You can optionally activate a timeout in order to close connections if unused for a certain ammount of time.
var slb = ; var router = slbrouters; var server = slbserver;server;