How to do load testing for websockets [closed]

2019-01-22 01:47发布

We are building a group chat feature, which is using websockets. We want to test how many connections our current infrastucture can support.

Basically it boils down to how to simulate a websocket.

6条回答
我欲成王,谁敢阻挡
2楼-- · 2019-01-22 01:52

I can give you a suggestion from my recent experience. You can connect webkit based Phantom virtual clients to your chat server and measure the resource usage (i.e CPU, memory, may be using a shell script or another utility or you can profile your service )

var system = require('system');
var page = require('webpage').create();
page.viewportSize = { width: 1024, height: 768 };

page.open("<URL to chat server service>", function (status) {
    // Check for page load success
    if (status !== "success") {
        console.log("Unable to connect");
        phantom.exit();
    } else {
        console.log("Client connected  ");
        //after connecting you may extract further information, taking screenshots etc. refer the phantom.js API for further details
    }
});

Do you use any framework like socket IO for websocket communication ?

查看更多
smile是对你的礼貌
3楼-- · 2019-01-22 01:56

You can use a load-testing tool for that.

I have used WebLOAD in a similar project. It records the web traffic when using the browser - it records regular HTTP requests and also the web-sockets traffic - you can then play the script back with many users and measure the server's behavior.

查看更多
我欲成王,谁敢阻挡
4楼-- · 2019-01-22 02:01

I had a nice experience with tsung http://tsung.erlang-projects.org/

查看更多
来,给爷笑一个
5楼-- · 2019-01-22 02:03

Several years have passed, there is another new tool to do load testing for Websockets: https://github.com/observing/thor

查看更多
手持菜刀,她持情操
6楼-- · 2019-01-22 02:04

How about using Jmeter for this purpose. Although it doesn't yet support WebSocket directly you can use TCP sampler to get the job done.

Alternatively you could get a plug-in which would add WebSocket support to JMeter: http://github.com/maciejzaleski/JMeter

Needless to say both JMeter and WebSocket plug-in is open-source and free to use.

查看更多
爷、活的狠高调
7楼-- · 2019-01-22 02:09

I would do it with Node.js so you can use the same websocket client library which you also use in the actual client.

查看更多
登录 后发表回答