Skip to content
This repository


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Charlie knows best

branch: master

Fetching latest commit…


Cannot retrieve the latest commit at this time

Octocat-spinner-32 demo
Octocat-spinner-32 lib
Octocat-spinner-32 test
Octocat-spinner-32 .gitignore
Octocat-spinner-32 .npmignore
Octocat-spinner-32 .travis.yml
Octocat-spinner-32 package.json

Charlie is a node module keeps of success and failures of network requests and adises on a delay between attempts using the backoff algorithm described in Exponential Backoff in Distributed Systems.

This module skips upto three failures before starting the backoff.

Travis status

Getting Charlie

npm install charlie



Before making a request to an origin, let charlie know. This functiont akes three arguments:

  • keys: An array of keys used to identify the network resource. For HTTP requests, the keys could be the URI of the resource, or the IP address, or the host name etc.
  • minDelay: Minimum backoff delay. As suggested in the blog post above, choose a value under which 99% of requests complete.
  • maxDelay: Maximum backoff delay. Choose an acceptable value based on availability requirements.

This function returns a decision with three fields:

  • state: values are go or nogo
  • count: number of failures so far. The count is reset after a success.
  • delay: currently applied backoff delay

Here is an example.

// Arr is an array of keys used to identify the network resource.
var decision = charlie.ask(arr, minDelay, maxDelay);
if(decision.state === 'go') {
    // make the request
else {
    // don't make the request
    console.log('Waiting until ' + decision.delay);


When a request succeeds, tell charlie.



When the request fails, tell charlie any way.



Forget everything about the resource.

Something went wrong with that request. Please try again.