Git Product home page Git Product logo

websocket-bench's Introduction

websocket bench Build Status

Nodejs cli tool for benchmarking websocket servers. Currently supports:

Installation

npm install -g websocket-bench

Running Tests/Linting

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

Usage

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>

Options:

  -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(socket.io, engine.io, faye, primus, wamp). Default to socket.io
  -p, --transport <type>   Type of transport to websocket(engine.io, websockets, browserchannel, sockjs, socket.io). 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) { });

         // Socket.io 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) { });

         done();
       },

       /**
        * 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' });
         // client.call('com.myapp.add2', [2, 3]).then(function (res) { });
         done();
       },

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

See also

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

websocket-bench's People

Contributors

nchaulet avatar balaphp avatar mbilbille avatar patspam avatar pronskiy avatar

Watchers

JJ avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.