in-process HTTP load balancer client with retries
In-process HTTP load balancer client with retries and backpressure for node.js.
If you use HTTP for IPC, or if you consume public APIs with HTTPS, then
lb_pool can help make your system more reliable, and possibly even faster.
lb_pool will use HTTP/1.1 keepalive to all of the available servers, distributing the load while maintaining and reusing TCP connections as appropriate. If a request fails due to a socket error or a user-defined failure condition, the request will be retried on another node. If there are too many pending requests into a pool, new requests are failed immediately to enforce backpressure and guard against cascading failures.
var LB_Pool = require"lb_pool";var servers ="10.0.0.1:8000""10.0.0.2:8000""10.0.0.3:8000";var auth_pool = require"http" serversmax_pending: 300ping: "/ping"timeout: 10000max_sockets: 2name: "auth";auth_poolget"/api/auth_validate?user=mjr"// handle error or response;
If your application consumes public APIs, you can get better performance and reliability by using
var LB_Pool = require"lb_pool";var servers ="api.facebook.com:443""api.facebook.com:443";var auth_pool = require"https" serversmax_pending: 10ping: "/ping"timeout: 10000max_sockets: 4name: "fb";auth_poolget"/me?token=aaaaaaaaaaaa"// handle error or response;