Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Lightweight load monitoring for node servers. Executes a range of callbacks as the instance's load rises and falls past specified thresholds.
CoffeeScript
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
src
LICENSE
README.md
package.json

README.md

Load Manager

About

Lightweight load manager for node.js-powered APIs. Executes a range of callbacks as an instance's load rises and falls. Load based on API calls, not server CPU load.

Install

npm install load-manager

Usage

As this is a lightweight module, we'll use restify for our server in preference to express.

# Require and instantiate restify and load-manager
api = require('restify').createServer()
loadManager = require('load-manager')()

# Start the server.
api.listen 8080, ->
  console.log 'listening at %s', api.url

# Load must be recorded manually.
# This can be achieved most simply as part of some middleware.
api.pre (req, res, next) ->
  loadManager.increment()

# It can also be weighted and associated with individal resources
# or methods.
api.put '/test', (req, res, next) ->
  loadManager.increment 5

averageLoad = loadmanager.getAverage()
Something went wrong with that request. Please try again.