зеркало из https://github.com/Azure/iisnode.git
websocket chatroom stress test
This commit is contained in:
Родитель
3a8ab565fc
Коммит
6b529f81c7
0
test/functional/node_modules/faye-websocket/CHANGELOG.txt → test/node_modules/faye-websocket/CHANGELOG.txt
сгенерированный
поставляемый
0
test/functional/node_modules/faye-websocket/CHANGELOG.txt → test/node_modules/faye-websocket/CHANGELOG.txt
сгенерированный
поставляемый
0
test/functional/node_modules/faye-websocket/README.markdown → test/node_modules/faye-websocket/README.markdown
сгенерированный
поставляемый
0
test/functional/node_modules/faye-websocket/README.markdown → test/node_modules/faye-websocket/README.markdown
сгенерированный
поставляемый
0
test/functional/node_modules/faye-websocket/examples/client.js → test/node_modules/faye-websocket/examples/client.js
сгенерированный
поставляемый
0
test/functional/node_modules/faye-websocket/examples/client.js → test/node_modules/faye-websocket/examples/client.js
сгенерированный
поставляемый
0
test/functional/node_modules/faye-websocket/examples/haproxy.conf → test/node_modules/faye-websocket/examples/haproxy.conf
сгенерированный
поставляемый
0
test/functional/node_modules/faye-websocket/examples/haproxy.conf → test/node_modules/faye-websocket/examples/haproxy.conf
сгенерированный
поставляемый
0
test/functional/node_modules/faye-websocket/examples/server.js → test/node_modules/faye-websocket/examples/server.js
сгенерированный
поставляемый
0
test/functional/node_modules/faye-websocket/examples/server.js → test/node_modules/faye-websocket/examples/server.js
сгенерированный
поставляемый
0
test/functional/node_modules/faye-websocket/examples/sse.html → test/node_modules/faye-websocket/examples/sse.html
сгенерированный
поставляемый
0
test/functional/node_modules/faye-websocket/examples/sse.html → test/node_modules/faye-websocket/examples/sse.html
сгенерированный
поставляемый
0
test/functional/node_modules/faye-websocket/examples/ws.html → test/node_modules/faye-websocket/examples/ws.html
сгенерированный
поставляемый
0
test/functional/node_modules/faye-websocket/examples/ws.html → test/node_modules/faye-websocket/examples/ws.html
сгенерированный
поставляемый
0
test/functional/node_modules/faye-websocket/lib/faye/websocket.js → test/node_modules/faye-websocket/lib/faye/websocket.js
сгенерированный
поставляемый
0
test/functional/node_modules/faye-websocket/lib/faye/websocket.js → test/node_modules/faye-websocket/lib/faye/websocket.js
сгенерированный
поставляемый
0
test/functional/node_modules/faye-websocket/package.json → test/node_modules/faye-websocket/package.json
сгенерированный
поставляемый
0
test/functional/node_modules/faye-websocket/package.json → test/node_modules/faye-websocket/package.json
сгенерированный
поставляемый
0
test/functional/node_modules/faye-websocket/spec/runner.js → test/node_modules/faye-websocket/spec/runner.js
сгенерированный
поставляемый
0
test/functional/node_modules/faye-websocket/spec/runner.js → test/node_modules/faye-websocket/spec/runner.js
сгенерированный
поставляемый
0
test/functional/node_modules/faye-websocket/spec/server.crt → test/node_modules/faye-websocket/spec/server.crt
сгенерированный
поставляемый
0
test/functional/node_modules/faye-websocket/spec/server.crt → test/node_modules/faye-websocket/spec/server.crt
сгенерированный
поставляемый
0
test/functional/node_modules/faye-websocket/spec/server.key → test/node_modules/faye-websocket/spec/server.key
сгенерированный
поставляемый
0
test/functional/node_modules/faye-websocket/spec/server.key → test/node_modules/faye-websocket/spec/server.key
сгенерированный
поставляемый
|
@ -0,0 +1,125 @@
|
|||
<html>
|
||||
<head>
|
||||
<title>130_websocket_chat</title>
|
||||
<script src="http://code.jquery.com/jquery-latest.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>130_websocket_chat</h1>
|
||||
<table>
|
||||
<tr>
|
||||
<td>Running time:</td>
|
||||
<td id="time"> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Messages sent:</td>
|
||||
<td id="sent"> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Messages received:</td>
|
||||
<td id="received"> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Websockets created:</td>
|
||||
<td id="wscount"> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Websocket errors:</td>
|
||||
<td id="errors"> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Distinct node.exe PIDs:</td>
|
||||
<td id="pids"> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Last RSS of node.exe:</td>
|
||||
<td id="rss"> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Last heap total of node.exe:</td>
|
||||
<td id="heaptotal"> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Last heap used of node.exe:</td>
|
||||
<td id="heapused"> </td>
|
||||
</tr>
|
||||
</table>
|
||||
<script>
|
||||
var start = new Date().getTime();
|
||||
var protocol = window.location.protocol === 'http:' ? 'ws://' : 'wss://';
|
||||
var address = protocol + window.location.host + window.location.pathname + '/server.js';
|
||||
var errors = 0;
|
||||
var wscount = 0;
|
||||
var sent = 0;
|
||||
var received = 0;
|
||||
var lastPID = -1;
|
||||
var pids = 0;
|
||||
var sendFrequency = 200;
|
||||
var maxErrors = 100;
|
||||
var maxWebSockets = 50;
|
||||
|
||||
function openSocket() {
|
||||
var socket = new WebSocket(address);
|
||||
wscount++;
|
||||
$('#wscount').html(wscount);
|
||||
if (wscount > maxWebSockets) {
|
||||
clearInterval(elapsedTime);
|
||||
return;
|
||||
}
|
||||
|
||||
socket.onmessage = function (msg) {
|
||||
var json = JSON.parse(msg.data);
|
||||
received++;
|
||||
$('#received').html(received);
|
||||
if (json.pid != lastPID) {
|
||||
pids++;
|
||||
lastPID = json.pid;
|
||||
$('#pids').html(pids);
|
||||
}
|
||||
$('#rss').html(json.memory.rss);
|
||||
$('#heaptotal').html(json.memory.heapTotal);
|
||||
$('#heapused').html(json.memory.heapUsed);
|
||||
};
|
||||
|
||||
socket.onerror = function (e) {
|
||||
errors++;
|
||||
$('#errors').html(errors);
|
||||
if (errors > maxErrors) {
|
||||
clearInterval(sendTimer);
|
||||
clearInterval(elapsedTime);
|
||||
}
|
||||
};
|
||||
|
||||
socket.onclose = function () {
|
||||
socket = null;
|
||||
openSocket();
|
||||
};
|
||||
|
||||
var sendTimer = setInterval(function () {
|
||||
if (socket) {
|
||||
socket.send('Check out the Websockets through iisnode!');
|
||||
sent++;
|
||||
$('#sent').html(sent);
|
||||
}
|
||||
else {
|
||||
clearInterval(sendTimer);
|
||||
}
|
||||
}, sendFrequency);
|
||||
}
|
||||
|
||||
var elapsedTime = setInterval(function () {
|
||||
var diff = new Date().getTime() - start;
|
||||
var days = Math.floor(diff / (24 * 3600 * 1000));
|
||||
diff %= (24 * 3600 * 1000);
|
||||
var hours = Math.floor(diff / (3600 * 1000));
|
||||
diff %= (3600 * 1000);
|
||||
var minutes = Math.floor(diff / (60 * 1000));
|
||||
diff %= (60 * 1000);
|
||||
var seconds = Math.floor(diff / 1000);
|
||||
$('#time').html(days + 'd ' + hours + 'h ' + minutes + 'm ' + seconds + 's');
|
||||
}, 1000);
|
||||
|
||||
openSocket();
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,44 @@
|
|||
|
||||
var WebSocket = require('faye-websocket')
|
||||
, http = require('http');
|
||||
|
||||
var server = http.createServer(function (req, res) {
|
||||
res.writeHead(400);
|
||||
res.end();
|
||||
});
|
||||
|
||||
var clients = {};
|
||||
var clientId = 0;
|
||||
|
||||
server.addListener('upgrade', function (request, socket, head) {
|
||||
var ws = new WebSocket(request, socket, head);
|
||||
ws.clientId = clientId++;
|
||||
clients[ws.clientId] = ws;
|
||||
|
||||
ws.onmessage = function (event) {
|
||||
var deadClients = [];
|
||||
for (var id in clients) {
|
||||
var ws = clients[id];
|
||||
try {
|
||||
ws.send(JSON.stringify({
|
||||
message: event.data,
|
||||
pid: process.pid,
|
||||
memory: process.memoryUsage()
|
||||
}));
|
||||
}
|
||||
catch (e) {
|
||||
deadClients.push(id);
|
||||
}
|
||||
}
|
||||
|
||||
deadClients.forEach(function (id) {
|
||||
delete clients[id];
|
||||
});
|
||||
};
|
||||
|
||||
ws.onclose = function (event) {
|
||||
delete clients[ws.clientId];
|
||||
};
|
||||
});
|
||||
|
||||
server.listen(process.env.PORT || 8888);
|
|
@ -0,0 +1 @@
|
|||
%systemroot%\system32\inetsrv\appcmd.exe add app /site.name:"Default Web Site" /path:/130_websocket_chat /physicalPath:%~dp0 /applicationPool:DefaultAppPool
|
|
@ -0,0 +1,8 @@
|
|||
<configuration>
|
||||
<system.webServer>
|
||||
<handlers>
|
||||
<add name="iisnode" path="server.js" verb="*" modules="iisnode" />
|
||||
</handlers>
|
||||
<webSocket enabled="false" />
|
||||
</system.webServer>
|
||||
</configuration>
|
Загрузка…
Ссылка в новой задаче