HTTP load/traffic generator and benchmark tool built on Node.js
Pull request Compare This branch is 40 commits ahead of benschmaus:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


This is a fork of benschmaus/nodeload. My current vision is to re-release nodeload as a separate npm module after restructuring for maintainability.

Documentation and usage may not be in sync for a while.


Make sure node.js is installed. Then install nodeload:

  1. Using npm:

     curl | sh       # install npm if not already installed
     npm install nodeload
  2. From source:

     git clone git://
     cd nodeload
     npm link    # optional. enables require('nodeload/<module>') instead of require('./lib/<module>').
  3. Or as a single file (this does not install the stress.js tool):



nodeload is a collection of independent node.js modules for load testing HTTP services.

As a developer, you should be able to write load tests and get informative reports without having to learn another framework. You should be able to build by example and selectively use the parts of a tool that fit your task. Being a library means that you can use as much or as little of nodeload as makes sense, and you can create load tests with the power of a full programming language. For example, if you need to execute some function at a given rate, just use the 'nodeload/loop' module, and write the rest yourself.

In addition, nodeload is built for operability. It can always be deployed by simply copying the single file, nodeload.js.

Look for examples in the examples/ directory and in test cases prefixed with "example" in test/. Here are simple examples of each module:


stress is an Apache Bench (ab) like command line tool for running tests quickly. Run ./bin/stress.js -h for usage information.

$ examples/test-server.js &    # starts a simple server on port 9000 to load test
$ ./bin/stress.js -c 10 -n 10000 -i 2 localhost:9000

will send 10,000 queries to http://localhost:9000 using 10 connections. Statistics are printed to the console and graphs can be seen at http://localhost:8000/.

Thanks to Orlando Vazquez for the original proof of concept app.


The nodeload module is the primary interface for creating load tests. It includes all the other modules described below, so if you require('nodeload'), you don't need to require() any of the other ones. Look at the examples in examples/loadtesting.ex.js and examples/riaktest.ex.js or read the nodeload module documentation.

var nl = require('nodeload');
var loadtest ={
    host: 'localhost',
    port: 9000,
    timeLimit: 60,
    targetRps: 500,
    requestGenerator: function(client) {
        var request = client.request('GET', "/" + Math.floor(Math.random()*10000));
        return request;
loadtest.on('end', function() { console.log('Load test done.'); });


The remote module provides a mechanism for running a distributed load test. See examples/remotetesting.ex.js and examples/remote.ex.js for examples or read the remote module documentation.

Start slave instances:

$ HTTP_PORT=10001 ./nodeload.js  # start a local slave instance on :10001
$ HTTP_PORT=10002 ./nodeload.js  # start a 2nd slave instance on :10002

Create the distributed load test:

var nl = require('nodeload/remote');
var cluster = new nl.LoadTestCluster('localhost:8000', ['localhost:8002', 'localhost:8001']);{
    host: 'localhost',
    port: 9000,
    timeLimit: 60,
    targetRps: 500,
    requestGenerator: function(client) {
        var request = client.request('GET', "/" + Math.floor(Math.random()*10000));
        return request;
cluster.on('end', function() { console.log('Load test done.'); });


The stats module provides implementations of various statistics objects, like Histograms and Accumulators, and functions, like randomString(), and nextGaussian(). See the stats module documentation.

var stats = require('nodeload/stats');
var histogram = new stats.Histogram();
for (var i = 0; i < 1000; i++) 
console.log('Mean: ' + histogram.mean() + ', 99%: ' + histogram.percentile(0.99));

will output "Mean: 0.852, 99%: 3".


The monitoring module provides a way to track runtime statistics for code that is run concurrently. See test/monitoring.test.js for examples or read the monitoring module documentation.

var monitoring = require('nodeload/monitoring');
var monitor = new monitoring.Monitor('runtime');
function asyncFunction() {
    var m = monitor.start();
    setTimeout(function() { m.end(); }, Math.floor(Math.random()*1000));
for (var i = 0; i < 1000; i++) { asyncFunction(); }
process.on('exit', function() {
    console.log('Median runtime (ms): ' + monitor.stats['runtime'].percentile(0.5));

will output "Median runtime (ms): 497".


The reporting module provides a way to graph values over time and present it in a auto-updating HTML page. See test/reporting.test.js for examples or read the reporting module documentation.

var reporting = require('nodeload/reporting'), 
    stats = require('nodeload/stats'),
    report = reporting.REPORT_MANAGER.addReport('Random Numbers'),
    chart = report.getChart('Gaussian / Pareto vs. Time (minutes)');
for (var timeout = 0; timeout < 5000; timeout+=500) {
    setTimeout(function() {
                'Pareto': stats.nextPareto(0, 100),
                'Gaussian': stats.nextGaussian()
        }, timeout);

will display a graph on http://localhost:8000/ and save it to an HTML file in the local directory.


The loop module provides a way to execute a function at a set rate and concurrency. See test/loop.test.js for examples or read the loop module documentation for details.

var http = require('http'),
    loop = require('nodeload/loop'),
    requests = 0,
    client = http.createClient(80, ''),
    l = new loop.MultiLoop({
        fun: function(finished) { 
            client.request('GET', '/').end();
        rps: 10,
        duration: 3,
        concurrency: 5
l.on('end', function() { console.log('Total requests: ' + requests) });

will output "Total requests: 30".


The http module provides a generic HTTP server that serves static files and that can be configured with new routes. See test/http.test.js for examples or read the http module documentation.

var http = require('nodeload/http');
var server = new http.HttpServer().start(10000);
server.addRoute('^/hello$', function(url, req, res) {

http://localhost:8000/package.json will output the contents of ./package.json, and http://localhost:10000/resource will display "Hello".


File bugs on github, email any of the authors, and fork away. doc/ has brief instructions on getting tests up and running, and will hold more design details in the future. Contributions are always welcome.