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
-a
Parameters 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