toobusy-js
Advanced tools
Comparing version 0.4.0 to 0.4.1
@@ -5,3 +5,3 @@ { | ||
"homepage": "https://github.com/STRML/node-toobusy", | ||
"version": "0.4.0", | ||
"version": "0.4.1", | ||
"dependencies": {}, | ||
@@ -8,0 +8,0 @@ "devDependencies": { |
@@ -0,1 +1,3 @@ | ||
[![Build Status](https://secure.travis-ci.org/STRML/node-toobusy.png)](http://travis-ci.org/STRML/node-toobusy) | ||
# Is Your Node Process Too Busy? | ||
@@ -8,6 +10,4 @@ | ||
## Original node-toobusy docs | ||
## Node-Toobusy | ||
[![Build Status](https://secure.travis-ci.org/STRML/node-toobusy.png)](http://travis-ci.org/STRML/node-toobusy) | ||
What happens when your service is overwhelmed with traffic? | ||
@@ -80,11 +80,19 @@ Your server can do one of two things: | ||
```javascript | ||
// set maximum lag to an aggressive value | ||
var toobusy = require('toobusy-js'); | ||
// Set maximum lag to an aggressive value. | ||
toobusy.maxLag(10); | ||
// Set check interval to a faster value. This will catch more latency spikes | ||
// but may cause the check to be too sensitive. | ||
toobusy.interval(250); | ||
// Get current maxLag or interval setting by calling without parameters. | ||
var currentMaxLag = toobusy.maxLag(), interval = toobusy.interval(); | ||
``` | ||
The default value is 70ms, | ||
which allows an "average" server to run at 90-100% CPU | ||
The default maxLag value is 70ms, and the default check interval is 500ms. | ||
This allows an "average" server to run at 90-100% CPU | ||
and keeps request latency at around 200ms. | ||
For comparison, a value of 10ms results in 60-70% CPU usage, | ||
For comparison, a maxLag value of 10ms results in 60-70% CPU usage, | ||
while latency for "average" requests stays at about 40ms. | ||
@@ -91,0 +99,0 @@ |
@@ -5,3 +5,3 @@ 'use strict'; | ||
// Constants | ||
// | ||
// | ||
var STANDARD_HIGHWATER = 70; | ||
@@ -15,3 +15,3 @@ var STANDARD_INTERVAL = 500; | ||
// | ||
// | ||
// Vars | ||
@@ -68,3 +68,3 @@ // | ||
/** | ||
* Set or get the current max latency threshold. Default is 70ms. | ||
* Set or get the current max latency threshold. Default is 70ms. | ||
* | ||
@@ -119,2 +119,5 @@ * Note that if event loop lag goes over this threshold, the process is not always 'too busy' - the farther | ||
// Kickoff the checking! | ||
start(); | ||
module.exports = toobusy; |
15136
316
115