Websocket-bench Test WebSocket

Source: Internet
Author: User
Tags emit yum repolist

Installation under CentOS6.5 environment

Check if the Epel is installed

Yum Repolist

If you do not see the Epel in the results, install it via the Yum command

Yum Install http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm

Start installing node. js After installing the above environment

sudo yum install Nodejs npm--enablerepo=epel

2 Installing Websocket-bench

Using NPM to install in a global manner

NPM install-g websocket-bench--registry=http://registry.npm.taobao.org

3websocket-bench use

Modify File Open number

Ulimit-n 60000

Using generator to customize test logic

Module.exports = {       //optional, beforeconnect:function is executed before connection is established       (client) {
}, //required, to do something after establishing the connection onconnect:function (client, done) { //Send message to Server
Client-side connection instances for clients
Client.emit (' getmessagelist ', ' {' Channelid ': ' 1609 '} '); callback function done (); }, //required, code to be run when sending a message to the server sendmessage:function (client, done) { Client.emit ( ' Getmessagelist ', ' {' Channelid ': ' 1609 '} ');
Done (); }, options: { //Realm: ' Chat ' } };

When you are finished writing, use the-G parameter to specify the generator file when you run Websocket-bench

Sometimes you need to modify the Socket.io protocol, located on line/usr/lib/node_modules/websocket-bench/lib/workers/socketioworker.js 18th

var client = Io.connect (this.server, {' force new Connection ': True, ' transports ': [' websocket ', ' polling ']});

Run Websocket-bench

Websocket-bench-a 10-c 1-g generator.js-k  http://localhost:20001/-  o opt.log

-aParameters specify the total number of tests, -c parameters specify concurrent connections, and parameters can be used to -o save the report to a separate file

For more use please see Https://github.com/M6Web/websocket-bench

4 Test Report

Launch Bench with ten total connection, 1 concurent connection
0 message (s) Send by client
1 worker (s)
WS Server:socket.io

Websocket-bench Test WebSocket

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.