【问题标题】:Weird behaviour with NodeJS and apache benchmarkNodeJS 和 apache 基准测试的奇怪行为
【发布时间】:2012-10-11 06:43:44
【问题描述】:

我正在测试 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/'

我得到相同的输出(日志中有很多“命中!”)

这是怎么回事?

这是特定于节点的,我用我的码头应用程序尝试过同样的方法,ab -c 1 -n 1,只有 1 次记录命中...

注意:我尝试过卷曲节点服务 - 只有 1 次“命中!”在日志中...

【问题讨论】:

  • 我遇到了同样的问题。我在 macOS sierra 上运行它。

标签: apache node.js apachebench


【解决方案1】:

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

来自nodejs群的原始回复:

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

这里也是描述问题的相关页面的direct link

【讨论】:

    【解决方案2】:

    这是怎么回事?

    每个“命中”都是新的连接。为什么在你看来它看起来不对?

    【讨论】:

    • 我只用 1 个线程和 1 个请求运行 ab。所以应该只有 1 次“命中!”
    猜你喜欢
    • 2013-11-22
    • 1970-01-01
    • 1970-01-01
    • 2012-06-27
    • 2019-07-30
    • 2012-05-14
    • 1970-01-01
    • 2014-01-25
    • 2020-06-26
    相关资源
    最近更新 更多