Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
N

node-toobusy

> 编程语言
Open source

Build Node.JS servers that don't fall over.

1.3K stars0 likes3 views
WebsiteGitHub

About

Build Node.JS servers that don't fall over.

Is Your Node Process Too Busy?

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.

How it works

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. At this point you can stop request processing early (before you spend too much time on them and compound the problem), and return a "Server Too Busy" response. This allows your server to stay responsive under extreme load, and continue serving as many requests as possible.

installation

bash
npm install toobusy

usage

javascript
var toobusy = require('toobusy'),
    express = require('express');
    
var app = express();
    
// middleware which blocks requests when we're too busy
app.use(function(req, res, next) {
  if (toobusy()) {
    res.send(503, "I'm busy right now, sorry.");
  } else {
    next();
  } 
});
    
app.get('/', function(req, res) {
  // processing the request requires some work!
  var i = 0;
  while (i  There is nothing new under the sun. (Ecclesiastes 1:9)

Though applying "event loop latency" to node.js was not directly inspired by anyone else's work,
this concept is not new.  Here are references to others who apply the same technique:

  * [Provos, Lever, and Tweedie 2000](http://www.kegel.com/c10k.html#tips) - "notes that dropping incoming connections when the server is overloaded improved the shape of the performance curve."

## license

[WTFPL](http://wtfpl.org)

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

JavaScript

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言