我想在我的socket.io服务器上运行Artillert进行负载测试,运行在localhost:8081。
这是socket.io部分:
io.on('connection', function (socket) {
console.log("new socket connected: " + socket.id);
socket.on("message", function (data) {
console.log("socket " + socket.id + " send message");
});
socket.on("disconnect", function (data) {
console.log("disconnect: " + socket.id)
})
});
剧本:
config:
target: "http://localhost:8081"
phases:
- duration: 1
arrivalRate: 1
scenarios:
- name: "connect and send message"
engine: "socketio"
flow:
- emit:
channel: "message"
data: "Blah Blah Blah"
这是服务器在控制台中打印的内容:
new socket connected: /#XC9WsjSeGw9hD7jZAAAA
new socket connected: /#NkVDJjHIO6DePiwNAAAB
socket /#NkVDJjHIO6DePiwNAAAB send message
disconnect: /#XC9WsjSeGw9hD7jZAAAA
disconnect: /#NkVDJjHIO6DePiwNAAAB
正如您所看到的,还有一个套接字,每个模拟用户总会再连接一个套接字。