# lb_pool

> in-process HTTP load balancer client with retries

Latest version **1.8.0** (published 2019-05-15) · 0 weekly downloads

## Install

```sh
npm install lb_pool
pnpm add lb_pool
yarn add lb_pool
bun add lb_pool
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.8.0 |
| Published | 2019-05-15 |
| First published | 2014-01-15 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 274.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 69 |
| Maintainers | anandsuresh, bahamas10, ezray303, jgautier, matt-esch, mjr, raynos, rf, sentientwaffle |

## Links

- npm: https://www.npmjs.com/package/lb_pool
- Repository: https://github.com/Voxer/lb_pool
- Homepage: https://github.com/Voxer/lb_pool#readme
- Issues: https://github.com/Voxer/lb_pool/issues
- npm.io page: https://npm.io/package/lb_pool

## Recent versions

- 1.8.0 (latest) — 2019-05-15
- 1.7.1 — 2017-04-19
- 1.7.0 — 2017-04-05
- 1.6.3 — 2016-11-07
- 1.6.2 — 2016-10-09
- 1.6.1 — 2016-10-09
- 1.6.0 — 2016-10-08
- 1.5.1 — 2016-10-04
- 1.5.0 — 2016-09-21
- 1.4.1 — 2016-09-06
- 1.4.0 — 2015-08-26
- 1.3.0 — 2015-05-01
- 1.2.0 — 2015-02-12
- 1.1.1 — 2015-01-08
- 1.1.0 — 2014-10-28
- … 2 more at https://npm.io/package/lb_pool/versions

## README

lb_pool
=======

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.

This module is inspired by and rewritten from [poolee](https://github.com/dannycoates/poolee), which is more actively maintained than `lb_pool`.

# Usage Example

```javascript

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 = new LB_Pool(require("http"), servers, {
    max_pending: 300,
    ping: "/ping",
    timeout: 10000,
    max_sockets: 2,
    name: "auth"
});

auth_pool.get("/api/auth_validate?user=mjr", function (err, res, body) {
    // handle error or response
});
```

# Consuming external APIs with HTTPS

If your application consumes public APIs, you can get better performance and reliability by using `lb_pool`:

```javascript

var LB_Pool = require("lb_pool");

var servers = [
    "api.facebook.com:443",
    "api.facebook.com:443"
];

var auth_pool = new LB_Pool(require("https"), servers, {
    max_pending: 10,
    ping: "/ping",
    timeout: 10000,
    max_sockets: 4,
    name: "fb"
});

auth_pool.get("/me?token=aaaaaaaaaaaa", function (err, res, body) {
    // handle error or response
});
```

---
_Source: https://npm.io/package/lb_pool · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
