Node.js - rejecting requests when server is melting!

Oscar Brito

Very useful indeed!

What happens when your service is overwhelmed with traffic? Your server can do one of two things:
  • Stop working, or...
  • Keep serving as many requests as possible
This library helps you do the latter.

toobusy polls the node.js event loop and keeps track of "lag", which is long requests wait in node's event queue to be processed. When lag crosses a threshold, toobusy tells you that you're too busy.

// middleware which blocks requests when we're too busyapp.use(function(req, res, next) {
if (toobusy()) {
res.send(503, "I'm busy right now, sorry.");
} else {


Visit for more informations, contacts and news about Web Development.
See other blog posts at

Divhide purpose is to follow the HTML5 movement and contribute with applications which prove the quality of technology.

Feel free to contact divhide.