apache - NodeJS 和 apache 基准测试的奇怪行为

标签 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.log('Server running at http://127.0.0.1:1337/');

我运行了 apache 基准测试:

ab -r -v 4 '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 特有的,我在我的码头应用程序中尝试了同样的方法,使用 ab -c 1 -n 1,只有 1 个记录的命中...

注意:我尝试过 curl Node 服务 - 只有 1 个“命中!”在日志中...

最佳答案

我也在 nodejs google 组中发布了这个。显然这是 apache/ab 的 macosx lion 版本中的错误。

nodejs群原回复:

https://groups.google.com/d/msg/nodejs/OqVZ4zPbqp0/DitO9xkmFOUJ

这里还有 direct link到描述问题的相关页面。

关于apache - NodeJS 和 apache 基准测试的奇怪行为,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12833673/

相关文章:

javascript - 将新的卡片对象推送到嵌套的对象数组中

node.js - 当我尝试在环回 (strongloop) web 应用程序中安装依赖项时出现 Npm 错误

json - Node 事件.js :167 throw er;//Unhandled 'error' event

Apache Bench - 请求失败

html - https 和 http 重定向

apache - htaccess 中路径的查询字符串有点工作吗?

sockets - 'ab' 程序在大量请求后卡住,为什么?

apachebench - ab 出现 apr_socket_recv : Connection refused (61) 错误

apache - Tomcat 托管具有多个 SSL 证书的多个虚拟主机

apache - mod_rewrite 问题 : RewriteCond %{REQUEST_FILENAME} ! -f 匹配,即使 REQUEST_FILENAME 不应(完全)匹配