问题描述
我们正在构建一个使用 websockets 的群聊功能.我们想测试我们当前的基础架构可以支持多少个连接.
We are building a group chat feature, which is using websockets. We want to test how many connections our current infrastucture can support.
基本上归结为如何模拟 websocket.
Basically it boils down to how to simulate a websocket.
推荐答案
我可以根据我最近的经验给你一个建议.您可以将基于 webkit 的 Phantom 虚拟客户端连接到您的聊天服务器并测量资源使用情况(即 CPU、内存,可能正在使用 shell 脚本或其他实用程序,或者您可以分析您的服务)
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
}
});
您是否使用套接字 IO 之类的任何框架进行 websocket 通信?
Do you use any framework like socket IO for websocket communication ?
这篇关于如何对 websockets 进行负载测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!