loopbusy
Middleware to send 503s and keep your server alive when it's too busy to queue more requests
Last updated 6 years ago by hunterloftis .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install loopbusy 
SYNC missed versions from official npm registry.

Loopbusy

Middleware to send 503s and keep your server alive when it's too busy to queue more requests.

var app = express();

app
  .use(loopbusy())
  .get('/', function sendOk(req, res, next) {
    res.send('ok');
  })
  .use(function handleErrors(err, req, res, next) {
    res.status(err.status).send('err');
  });

Loopbusy uses the event-loop-lag module to determine when the event loop is piling up requests.

When lag passes a threshold, loopbusy passes 503 errors to your middleware stack so your app can stay alive for some users instead of falling over for all users.

Options

loopbusy(maxLag, pollingInterval);

Max Lag

loopbusy(500);

The maximum lag (in ms) of your event loop.

Defaults to 250.

Interval

loopbusy(null, 3000);

The polling interval (in ms) for measuring your event loop. Shorter values catch business faster at the cost of additional overhead.

Defaults to 1000.

Tests

npm test

Current Tags

  • 1.0.1                                ...           latest (6 years ago)

2 Versions

  • 1.0.1                                ...           6 years ago
  • 1.0.0                                ...           6 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (1)
Dev Dependencies (4)

Copyright 2014 - 2016 © taobao.org |