workerman gatewayworker websocket 性能测试结果

没有一个好的websocket测试工具
我用nodejs大致写了一个,测试1核1g维持1000个websocket
测试代码如下所示

var WebSocketClient = require('websocket').client;
let first = 0;
for (let i = 0; i < 1000; i++) {
    let client = new WebSocketClient();
    client.on('connectFailed', function(error) {
        console.log('Connect Error: ' + error.toString());
    });
    client.on('connect', function(connection) {
        connection.on('error', function(error) {
            console.log("Connection Error: " + error.toString());
        });
        connection.on('close', function() {
            console.log('Connection Closed');
        });
        connection.on('message', function(message) {
            if (first == 0) {
                console.log(message.utf8Data)
                first++;
            }
            connection.sendUTF('{"msg":"beat"}');
        });
    });
    client.connect('ws://115.159.106.28:8585/');
}

测试结果

----------------------------------------------PROCESS STATUS---------------------------------------------------
pid memory  listening                worker_name           connections send_fail timers  total_request qps    status
14056   2M      none                     YourAppBusinessWorker 2           0         0       1526          0      [idle]
14057   2M      none                     YourAppBusinessWorker 2           0         0       1478          0      [idle]
14058   6M      websocket://0.0.0.0:8585 websocket             1003        0         1       2002          0      [idle]
14060   2M      text://0.0.0.0:1238      Register              3           0         0       3             0      [idle]
----------------------------------------------PROCESS STATUS---------------------------------------------------
Summary 12M     -                        -                     1010        0         1       5009          0      [Summary]

使用本地脚本测试通过websocket维持住1000个请求只用了12M内存,还有非常大的提升空间

相关文章

此处评论已关闭