NodeJS和apache基准测试的奇怪行为
我正在测试nodejs(0.8.11) 使用以下服务器应用程序:NodeJS和apache基准测试的奇怪行为,apache,node.js,apachebench,Apache,Node.js,Apachebench,我正在测试nodejs(0.8.11) 使用以下服务器应用程序: var http = require('http'); http.createServer(function (req, res) { console.log('hit!'); res.writeHead(200, {'Content-Type': 'text/plain'}); res.end('Hello World\n'); }).listen(1337, '127.0.0.1'); console.
var http = require('http');
http.createServer(function (req, res) {
console.log('hit!');
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World\n');
}).listen(1337, '127.0.0.1');
console.log('Server running at http://127.0.0.1:1337/');
我运行了apache基准测试:
ab-r-v4'http://127.0.0.1:1337/"
我得到以下输出:
hit!
hit!
hit!
hit!
hit!
hit!
hit!
hit!
hit!
... (alot more)
ab的输出:
Benchmarking 127.0.0.1 (be patient)...INFO: POST header ==
---
GET / HTTP/1.0
Host: 127.0.0.1:1337
User-Agent: ApacheBench/2.3
Accept: */*
---
LOG: header received:
HTTP/1.1 200 OK
Content-Type: text/plain
Date: Thu, 11 Oct 2012 06:40:04 GMT
Connection: close
Hello World
LOG: Response code = 200
..done
Server Software:
Server Hostname: 127.0.0.1
Server Port: 1337
Document Path: /
Document Length: 12 bytes
Concurrency Level: 1
Time taken for tests: 0.009 seconds
Complete requests: 1
Failed requests: 0
Write errors: 0
Total transferred: 113 bytes
HTML transferred: 12 bytes
Requests per second: 115.05 [#/sec] (mean)
Time per request: 8.692 [ms] (mean)
Time per request: 8.692 [ms] (mean, across all concurrent requests)
Transfer rate: 12.70 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 8 8 0.0 8 8
Processing: 0 0 0.0 0 0
Waiting: 0 0 0.0 0 0
Total: 9 9 0.0 9 9
考虑到ab手册中规定的默认请求数不是1,我尝试:
ab -v 4 -n 1 -c 1 'http://127.0.0.1:1337/'
我得到了相同的输出(日志中有很多“点击次数”)
这是怎么回事
这是特定于node的,我在jetty应用程序中也尝试过同样的方法,使用ab-c1-n1,只记录了1次命中
注意:我已经尝试过卷曲节点服务-只点击了1次在日志中
这是怎么回事
每个“命中”都是新的连接。从你的观点来看,为什么它看起来是错误的?我也在nodejs谷歌群中发布了这篇文章。显然,这是macosx lion版apache/ab中的一个bug 来自nodejs组的原始答复:
这里还有描述问题的相关页面的链接。我只使用一个线程和一个请求运行ab。所以应该只有1个‘命中’我遇到了同样的问题。我在macOS sierra上运行它。