admin管理员组文章数量:1333695
Is there a way in node.js
to get the number of open connections and number of requests per second from a http server?
Assume the following simple server:
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end("Hello World!");
}).listen(80);
Thanks.
Is there a way in node.js
to get the number of open connections and number of requests per second from a http server?
Assume the following simple server:
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end("Hello World!");
}).listen(80);
Thanks.
Share Improve this question asked May 10, 2013 at 7:23 JustinJustin 45.4k83 gold badges213 silver badges310 bronze badges 3- You can use ApacheBench or httperf. – robertklep Commented May 10, 2013 at 7:32
- I want these numbers from the server (node.js), not client. – Justin Commented May 10, 2013 at 7:35
- Ah right. Check out node-measured. – robertklep Commented May 10, 2013 at 7:51
1 Answer
Reset to default 9This is what I usually do when I want to double-check numbers ab/httperf/wrk/siege report:
var served = 0;
var concurrent = 0;
http.createServer(function (req, res) {
concurrent++;
res.writeHead(200, {'Content-Type': 'text/plain'});
setTimeout(function() { // emulate some async delay
served++;
concurrent--;
res.end("Hello World!");
}, 10);
}).listen(80);
setInterval(function() {
console.log('Requests per second:' + served);
console.log('Concurrent requests:' + concurrent);
served = 0;
}, 1000);
本文标签: javascriptGet requests per second from nodejs http serverStack Overflow
版权声明:本文标题:javascript - Get requests per second from node.js http server - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742269641a2444061.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论