{"_id":"toobusy","_rev":"62-16b38590bb50a4ae093a4925ef43cd2f","name":"toobusy","description":"Don't fall over when your Node.JS server is too busy.","dist-tags":{"latest":"0.2.4"},"versions":{"0.0.1":{"name":"toobusy","description":"Don't fall over when your Node.JS server is too busy.","homepage":"https://github.com/lloyd/node-toobusy","version":"0.0.1","maintainers":[{"name":"lloyd","email":"lloyd@hilaiel.com"}],"bugs":{"url":"https://github.com/lloyd/node-toobusy/issues"},"licenses":[{"type":"WTFPL"}],"repositories":[{"type":"git","url":"git://github.com/lloyd/node-toobusy.git"}],"main":"./index.js","engines":{"node":">=0.6.0"},"_id":"toobusy@0.0.1","dist":{"shasum":"32aca146848541573c252be4d677aca84c8e5357","tarball":"https://registry.npmjs.org/toobusy/-/toobusy-0.0.1.tgz","integrity":"sha512-fV/Hv9cMt2M/VMLFa1MPHTnm4QevxtgDjBWFoOlj08YboPQ0emKHdrF+wxIFqkluAp4qNVgFh5fmEgnu4SrLBg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCV9vQpTGu4mty5QuN8xE2OBf+OskicU9bEMUHc9in3agIhAJPbxEjkJVqYDwpEJErbEmqnFSA2sGKdvHMF/bsvHxaP"}]},"_npmVersion":"1.1.65","_npmUser":{"name":"lloyd","email":"lloyd@hilaiel.com"},"directories":{}},"0.1.0":{"name":"toobusy","description":"Don't fall over when your Node.JS server is too busy.","homepage":"https://github.com/lloyd/node-toobusy","version":"0.1.0","dependencies":{"bindings":"1.0.0"},"maintainers":[{"name":"lloyd","email":"lloyd@hilaiel.com"}],"bugs":{"url":"https://github.com/lloyd/node-toobusy/issues"},"licenses":[{"type":"WTFPL"}],"repositories":[{"type":"git","url":"git://github.com/lloyd/node-toobusy.git"}],"main":"./index.js","engines":{"node":">=0.6.0"},"scripts":{"install":"node-gyp rebuild"},"gypfile":true,"_id":"toobusy@0.1.0","dist":{"shasum":"a6adc4790aa1588afa9593818d2bd05fae6469dc","tarball":"https://registry.npmjs.org/toobusy/-/toobusy-0.1.0.tgz","integrity":"sha512-mgguFvt4wO5mRFz28QS5Nc/kNL3Q9Wgq32x/gK/Ar746C4/nmWLrlFnYsH8rf819nueLt4DRbSAIlj7aEH32zw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIFUw9BYcpaoq7oiJZ1JckiSGWjlWbGP26q96XWWtv8tRAiBp7vGMJd3b/tLYXVvDZJ/lVunJhLCIBNgoQcdl5/Ssfg=="}]},"_npmVersion":"1.1.65","_npmUser":{"name":"lloyd","email":"lloyd@hilaiel.com"},"directories":{}},"0.1.1":{"name":"toobusy","description":"Don't fall over when your Node.JS server is too busy.","homepage":"https://github.com/lloyd/node-toobusy","version":"0.1.1","dependencies":{"bindings":"1.0.0"},"devDependencies":{"should":"1.2.1","mocha":"1.7.0"},"maintainers":[{"name":"lloyd","email":"lloyd@hilaiel.com"}],"bugs":{"url":"https://github.com/lloyd/node-toobusy/issues"},"licenses":[{"type":"WTFPL"}],"repositories":[{"type":"git","url":"git://github.com/lloyd/node-toobusy.git"}],"main":"./index.js","engines":{"node":">=0.8.0"},"scripts":{"test":"mocha tests","install":"node-gyp rebuild"},"gypfile":true,"_id":"toobusy@0.1.1","dist":{"shasum":"267a16542980be4bab0acfbae22f594a6b52d323","tarball":"https://registry.npmjs.org/toobusy/-/toobusy-0.1.1.tgz","integrity":"sha512-tIT9pPYNfepUOUQLt/eOs7rMrCTRyNKmIoTJ9RyBixLjMa9eGFXdT1xS20jSh2DMUEp840WX875RK+5R0I31ug==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDwZqU9qtD4pukmrPusYrZ+DMhWUcMDVKIsHWT4XJR2LAIhANwQ9td+NEJDdxHpIq7OwO560rNUvbrc76DMcF0LdYa/"}]},"_npmVersion":"1.1.65","_npmUser":{"name":"lloyd","email":"lloyd@hilaiel.com"},"directories":{}},"0.2.0":{"name":"toobusy","description":"Don't fall over when your Node.JS server is too busy.","homepage":"https://github.com/lloyd/node-toobusy","version":"0.2.0","dependencies":{"bindings":"1.0.0"},"devDependencies":{"should":"1.2.1","mocha":"1.7.0"},"maintainers":[{"name":"lloyd","email":"lloyd@hilaiel.com"}],"bugs":{"url":"https://github.com/lloyd/node-toobusy/issues"},"licenses":[{"type":"WTFPL"}],"repositories":[{"type":"git","url":"git://github.com/lloyd/node-toobusy.git"}],"main":"./index.js","engines":{"node":">=0.8.0"},"scripts":{"test":"mocha tests","install":"node-gyp rebuild"},"gypfile":true,"_id":"toobusy@0.2.0","dist":{"shasum":"bc69a7544fcd6996828aca7161920ea0d061eec1","tarball":"https://registry.npmjs.org/toobusy/-/toobusy-0.2.0.tgz","integrity":"sha512-tthtpK0bwwpaLQB8SS+ip7h5Le9UurlP1Fdn6T5zeDmZev0sXSf+bincou8YgO2NNwgl/eP4xeeX2ModODtSeA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIHrei3C2xBz1E6bISmbKEbEEoJWJR11LqIxi7GeYHwvMAiEA70DNrVJBt/oTfsnHUW+fu6q/orUSPRM8yNngOM6oWfs="}]},"_npmVersion":"1.2.0","_npmUser":{"name":"lloyd","email":"lloyd@hilaiel.com"},"directories":{}},"0.2.1":{"name":"toobusy","description":"Don't fall over when your Node.JS server is too busy.","homepage":"https://github.com/lloyd/node-toobusy","version":"0.2.1","dependencies":{"bindings":"1.0.0"},"devDependencies":{"should":"1.2.1","mocha":"1.7.0"},"maintainers":[{"name":"lloyd","email":"lloyd@hilaiel.com"}],"bugs":{"url":"https://github.com/lloyd/node-toobusy/issues"},"licenses":[{"type":"WTFPL"}],"repositories":[{"type":"git","url":"git://github.com/lloyd/node-toobusy.git"}],"main":"./index.js","engines":{"node":">=0.8.0"},"scripts":{"test":"mocha tests","install":"node-gyp rebuild"},"gypfile":true,"_id":"toobusy@0.2.1","dist":{"shasum":"032feb3cd2fa56ddfde3284e267f679f1fdf43c6","tarball":"https://registry.npmjs.org/toobusy/-/toobusy-0.2.1.tgz","integrity":"sha512-Bwu1REIozsMW/UqNRWjH5sGep1zRrDrbX/MGGoIS8rEIXYpdR0C2iiycGz9WM0YeqipSsJ8T44YdV54lfJ7kAg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIFibKDSov4N+tIBbhexZlMc7M1sVaVsEfHymsAzyN51aAiAt0GpfrBvIa1TQg831APSQbii8t+FnQ/SQXGHsDx0tMQ=="}]},"_npmVersion":"1.1.65","_npmUser":{"name":"lloyd","email":"lloyd@hilaiel.com"},"directories":{}},"0.2.2":{"name":"toobusy","description":"Don't fall over when your Node.JS server is too busy.","homepage":"https://github.com/lloyd/node-toobusy","version":"0.2.2","dependencies":{"bindings":"1.0.0"},"devDependencies":{"should":"1.2.1","mocha":"1.7.0"},"maintainers":[{"name":"lloyd","email":"lloyd@hilaiel.com"}],"bugs":{"url":"https://github.com/lloyd/node-toobusy/issues"},"licenses":[{"type":"WTFPL"}],"repositories":[{"type":"git","url":"git://github.com/lloyd/node-toobusy.git"}],"main":"./index.js","engines":{"node":">=0.8.0"},"scripts":{"test":"mocha tests","install":"node-gyp rebuild"},"gypfile":true,"_id":"toobusy@0.2.2","dist":{"shasum":"80edb87f2af7aa4c62958292ba65e89c839cb6f1","tarball":"https://registry.npmjs.org/toobusy/-/toobusy-0.2.2.tgz","integrity":"sha512-MRe/mUc5+vCLESnlU8gTsvyiFK5EkbUseE8ZqfZ84ur2pOtVp9c3k0kiod52MKT81NuEjwAG95QOJTDzZDpIvA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCICG3rr5IOXppNL0z2WVbUE5ze5UiP/ON7qn+jVFz0dlvAiB0Dxo7K46MjkrFlm0tedRKPVPGDF3G1RL+MIj2WbYHhA=="}]},"_from":".","_npmVersion":"1.2.2","_npmUser":{"name":"lloyd","email":"lloyd@hilaiel.com"},"directories":{}},"0.2.3":{"name":"toobusy","description":"Don't fall over when your Node.JS server is too busy.","homepage":"https://github.com/lloyd/node-toobusy","version":"0.2.3","dependencies":{"bindings":"1.1.0"},"devDependencies":{"should":"1.2.1","mocha":"1.7.0"},"maintainers":[{"name":"lloyd","email":"lloyd@hilaiel.com"}],"bugs":{"url":"https://github.com/lloyd/node-toobusy/issues"},"licenses":[{"type":"WTFPL"}],"repositories":[{"type":"git","url":"git://github.com/lloyd/node-toobusy.git"}],"main":"./index.js","engines":{"node":">=0.8.0"},"scripts":{"test":"mocha tests","install":"node-gyp rebuild"},"gypfile":true,"_id":"toobusy@0.2.3","dist":{"shasum":"c5de5d98adfb1192190d70e5b3a6a9fd3d08db72","tarball":"https://registry.npmjs.org/toobusy/-/toobusy-0.2.3.tgz","integrity":"sha512-gLDsvzjDiYcGrTp84EcBH38Jp+MZ30BwSfomhEzIyTS9z7Zg3PSgBwPi5LfhInveX36JTEizFPsmZxk4Ip6tJw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQC89qbo3JmHy/Ta6zAG+yypBirIYXpwrkfQnM6QdQl5IQIhANvQvmftYhWVx2rqDsrHWZ3Mqne9GpnRLNQqmIuABP+g"}]},"_from":".","_npmVersion":"1.2.11","_npmUser":{"name":"lloyd","email":"lloyd@hilaiel.com"}},"0.2.4":{"name":"toobusy","description":"Don't fall over when your Node.JS server is too busy.","homepage":"https://github.com/lloyd/node-toobusy","version":"0.2.4","dependencies":{"bindings":"1.1.0"},"devDependencies":{"should":"1.2.1","mocha":"1.7.0"},"maintainers":[{"name":"lloyd","email":"lloyd@hilaiel.com"}],"bugs":{"url":"https://github.com/lloyd/node-toobusy/issues"},"licenses":[{"type":"WTFPL"}],"repository":{"type":"git","url":"git://github.com/lloyd/node-toobusy.git"},"main":"./index.js","engines":{"node":">=0.8.0"},"scripts":{"test":"mocha tests","install":"node-gyp rebuild"},"gypfile":true,"_id":"toobusy@0.2.4","dist":{"shasum":"d97a3ee760b2462388e15f8526579b4b64bb193d","tarball":"https://registry.npmjs.org/toobusy/-/toobusy-0.2.4.tgz","integrity":"sha512-lXPSwIlqcb9p9mpTvi4VtujrnAq7NUq4sKJVCoKylOcrurKVLXWONX5l69D8fuSKvkb67kD2bXfOzvAg9MVK5A==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIBnbZBkXPrI4WjjfYqh/fcwb7CYYKQ3wZiV5WB3RL3LVAiBXVcLCBlrjixHExQhkPTC1pzncKtBTzwI/JvohndUcfQ=="}]},"_from":".","_npmVersion":"1.3.11","_npmUser":{"name":"lloyd","email":"lloyd@hilaiel.com"}}},"readme":"# Is Your Node Process Too Busy?\n\n[![Build Status](https://secure.travis-ci.org/lloyd/node-toobusy.png)](http://travis-ci.org/lloyd/node-toobusy)\n\nWhat happens when your service is overwhelmed with traffic?\nYour server can do one of two things:\n\n  * Stop working, or...\n  * Keep serving as many requests as possible\n\nThis library helps you do the latter.\n\n## How it works\n\n`toobusy` polls the node.js event loop and keeps track of \"lag\",\nwhich is long requests wait in node's event queue to be processed.\nWhen lag crosses a threshold, `toobusy` tells you that you're *too busy*.\nAt this point you can stop request processing early\n(before you spend too much time on them and compound the problem),\nand return a \"Server Too Busy\" response.\nThis allows your server to stay *responsive* under extreme load,\nand continue serving as many requests as possible.\n\n## installation\n\n```\nnpm install toobusy\n```\n\n\n## usage\n\n```javascript\nvar toobusy = require('toobusy'),\n    express = require('express');\n    \nvar app = express();\n    \n// middleware which blocks requests when we're too busy\napp.use(function(req, res, next) {\n  if (toobusy()) {\n    res.send(503, \"I'm busy right now, sorry.\");\n  } else {\n    next();\n  } \n});\n    \napp.get('/', function(req, res) {\n  // processing the request requires some work!\n  var i = 0;\n  while (i < 1e5) i++;\n  res.send(\"I counted to \" + i);\n});\n  \nvar server = app.listen(3000);\n  \nprocess.on('SIGINT', function() {\n  server.close();\n  // calling .shutdown allows your process to exit normally\n  toobusy.shutdown();\n  process.exit();\n});\n```\n\n## tunable parameters\n\nThe one knob that the library exposes is \"maximum lag\".\nThis number represents the maximum amount of time in milliseconds that the event queue is behind,\nbefore we consider the process *too busy*.\n\n```javascript\n// set maximum lag to an aggressive value\nrequire('toobusy').maxLag(10);\n```\n\nThe default value is 70ms,\nwhich allows an \"average\" server to run at 90-100% CPU\nand keeps request latency at around 200ms.\nFor comparison, a value of 10ms results in 60-70% CPU usage,\nwhile latency for \"average\" requests stays at about 40ms.\n\nThese numbers are only examples,\nand the specifics of your hardware and application can change them drastically,\nso experiment!\nThe default of 70 should get you started.\n\n## references\n\n> There is nothing new under the sun. (Ecclesiastes 1:9)\n\nThough applying \"event loop latency\" to node.js was not directly inspired by anyone else's work,\nthis concept is not new.  Here are references to others who apply the same technique:\n\n  * [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.\"\n\n## license\n\n[WTFPL](http://wtfpl.org)\n","maintainers":[{"name":"lloyd","email":"lloyd@hilaiel.com"},{"name":"gene_wood","email":"npmjs.org@ewood.users.cementhorizon.com"},{"name":"dannycoates","email":"dannycoates@gmail.com"}],"time":{"modified":"2022-06-27T18:23:42.969Z","created":"2012-11-16T17:00:49.223Z","0.0.1":"2012-11-16T17:00:50.015Z","0.1.0":"2012-11-17T22:12:59.348Z","0.1.1":"2012-11-17T22:41:34.095Z","0.2.0":"2013-01-16T23:05:30.145Z","0.2.1":"2013-01-17T15:53:53.466Z","0.2.2":"2013-01-29T19:28:23.206Z","0.2.3":"2013-03-12T15:37:35.151Z","0.2.4":"2013-10-14T08:21:24.711Z"},"users":{"taterbase":true,"werle":true,"maxmaximov":true,"louist":true,"detj":true,"jdcauley":true,"codeshrew":true,"uwo":true,"glukki":true,"ajohnstone":true,"alanshaw":true,"eymen":true,"givan":true,"hengkiardo":true,"kerimdzhanov":true,"mikejoseph":true,"niklasi":true,"amoiseev":true,"clholzin":true,"dwayneford":true,"monkeymonk":true,"justinshea":true,"spiros.politis":true,"zurbaev":true,"paragi":true,"nickeltobias":true,"taddei":true,"shanewholloway":true,"garenyondem":true},"repository":{"type":"git","url":"git://github.com/lloyd/node-toobusy.git"},"homepage":"https://github.com/lloyd/node-toobusy","bugs":{"url":"https://github.com/lloyd/node-toobusy/issues"},"readmeFilename":"README.md"}