nodejs tool to benchmark and faye websocket server
Switch branches/tags
Nothing to show
Clone or download
Latest commit a6a3c26 May 12, 2015

websocket bench Build Status

Nodejs cli tool for benchmarking websocket servers. Currently supports:


npm install -g websocket-bench

Running Tests/Linting

First Install required dev-dependencies npm install Run Gulp Build Tool gulp mocha


Tip: You may find it useful to increase the maximum number of open file descriptors on your system during testing:

ulimit -n 60000

Simple example (using Socket.IO by default):

websocket-bench -a 2500 -c 200 http://localhost:3000

Simple example (using Primus):

websocket-bench -t primus ws://localhost:8080

command help

Usage: websocket-bench [options] <server>


  -h, --help               Output usage information
  -V, --version            Output the version number
  -a, --amount <n>         Total number of persistent connection, Default to 100
  -c, --concurency <n>     Concurent connection per second, Default to 20
  -w, --worker <n>         Number of worker(s)
  -g, --generator <file>   Js file for generate message or special event
  -m, --message <n>        Number of message for a client. Default to 0
  -o, --output <output>    Output file
  -t, --type <type>        Type of websocket server to bench(,, faye, primus, wamp). Default to
  -p, --transport <type>   Type of transport to websocket(, websockets, browserchannel, sockjs, Default to websockets (Just for Primus)
  -k, --keep-alive         Keep alive connection
  -v, --verbose            Verbose Logging

Benchmark message

For benchmark message or more advanced connection you should provide your own generator

generator structure :

    module.exports = {
        * Before connection (optional, just for faye)
        * @param {client} client connection
       beforeConnect : function(client) {
         // Example:
         // client.setHeader('Authorization', 'OAuth abcd-1234');
         // client.disable('websocket');

        * On client connection (required)
        * @param {client} client connection
        * @param {done} callback function(err) {}
       onConnect : function(client, done) {
         // Faye client
         // client.subscribe('/channel', function(message) { });

         // client
         // client.emit('test', { hello: 'world' });

         // Primus client
         // client.write('Sailing the seas of cheese');

         // WAMP session
         // client.subscribe('com.myapp.hello').then(function(args) { });


        * Send a message (required)
        * @param {client} client connection
        * @param {done} callback function(err) {}
       sendMessage : function(client, done) {
         // Example:
         // client.emit('test', { hello: 'world' });
         // client.publish('/test', { hello: 'world' });
         //'com.myapp.add2', [2, 3]).then(function (res) { });

        * WAMP connection options
       options : {
         // realm: 'chat'

See also

French article about websocket-bench : Benchmarking websockets avec Node.Js