【问题标题】:Why are clinic.js and Autocannon returning 0 2xx responses, 36164 non 2xx responses?为什么 Clinic.js 和 Autocannon 返回 0 2xx 响应,36164 非 2xx 响应?
【发布时间】:2021-10-25 16:50:25
【问题描述】:

我有一个 nodejs 网络服务,我想使用 Clinic.js 来分析它的性能并找到瓶颈。

所以当我发出这个命令时:

clinic doctor --on-port 'autocannon localhost:$PORT --connections 5 -m "POST" -i my-data.json -H "Authorization":"Bearer xxx" ' -- node ./dist/custom/index.js

我得到下一个日志:

Running 10s test @ http://localhost:443
5 connections

┌─────────┬──────┬──────┬───────┬──────┬──────┬───────┬──────┐
│ Stat    │ 2.5% │ 50%  │ 97.5% │ 99%  │ Avg  │ Stdev │ Max  │
├─────────┼──────┼──────┼───────┼──────┼──────┼───────┼──────┤
│ Latency │ 0 ms │ 0 ms │ 0 ms  │ 0 ms │ 0 ms │ 0 ms  │ 0 ms │
└─────────┴──────┴──────┴───────┴──────┴──────┴───────┴──────┘
┌───────────┬─────┬──────┬─────┬───────┬─────┬───────┬─────┐
│ Stat      │ 1%  │ 2.5% │ 50% │ 97.5% │ Avg │ Stdev │ Min │
├───────────┼─────┼──────┼─────┼───────┼─────┼───────┼─────┤
│ Req/Sec   │ 0   │ 0    │ 0   │ 0     │ 0   │ 0     │ 0   │
├───────────┼─────┼──────┼─────┼───────┼─────┼───────┼─────┤
│ Bytes/Sec │ 0 B │ 0 B  │ 0 B │ 0 B   │ 0 B │ 0 B   │ 0 B │
└───────────┴─────┴──────┴─────┴───────┴─────┴───────┴─────┘

Req/Bytes counts sampled once per second.

63k requests in 11.01s, 0 B read
63k errors (0 timeouts)
USMCDANCN2Z76AB:172542_alexa_skills_template xzxqdy$ clinic doctor --on-port 'autocannon localhost:$PORT --connections 5 -m "POST" -i my-data.json -H "Authorization":"Bearer xxx" ' -- node ./dist/custom/index.js
Running 10s test @ http://localhost:443
5 connections

running [                    ] 0%
┌─────────┬──────┬──────┬───────┬──────┬─────────┬─────────┬───────┐
│ Stat    │ 2.5% │ 50%  │ 97.5% │ 99%  │ Avg     │ Stdev   │ Max   │
├─────────┼──────┼──────┼───────┼──────┼─────────┼─────────┼───────┤
│ Latency │ 1 ms │ 1 ms │ 2 ms  │ 3 ms │ 1.07 ms │ 0.48 ms │ 20 ms │
└─────────┴──────┴──────┴───────┴──────┴─────────┴─────────┴───────┘
┌───────────┬─────────┬─────────┬─────────┬─────────┬─────────┬────────┬─────────┐
│ Stat      │ 1%      │ 2.5%    │ 50%     │ 97.5%   │ Avg     │ Stdev  │ Min     │
├───────────┼─────────┼─────────┼─────────┼─────────┼─────────┼────────┼─────────┤
│ Req/Sec   │ 2427    │ 2427    │ 3821    │ 3939    │ 3616.8  │ 440.53 │ 2427    │
├───────────┼─────────┼─────────┼─────────┼─────────┼─────────┼────────┼─────────┤
│ Bytes/Sec │ 2.14 MB │ 2.14 MB │ 3.36 MB │ 3.47 MB │ 3.18 MB │ 388 kB │ 2.14 MB │
└───────────┴─────────┴─────────┴─────────┴─────────┴─────────┴────────┴─────────┘

Req/Bytes counts sampled once per second.

0 2xx responses, 36164 non 2xx responses
36k requests in 10.01s, 31.8 MB read
Analysing data
Generated HTML file is 

那么为什么我会收到?:0 个 2xx 响应,36164 个非 2xx 响应 当我在邮递员中尝试使用相同的标题和正文时,它返回 200。

提前感谢您的帮助

问候

【问题讨论】:

    标签: node.js performance web-services


    【解决方案1】:

    我也有同样的问题。当您将 autocannon 作为内部命令运行时,似乎没有正确处理标题。我尝试了许多不同的语法。

    什么对我有用:在单独的终端中运行 node clinic doctor/flameautocannon

    首先在终端 A 运行:

    clinic doctor -- node ./dist/custom/index.js
    

    在第二个终端B运行:

    autocannon localhost:<YourPort> --connections 5 -m "POST" -i my-data.json -H "Authorization":"Bearer xxx" 
    

    autocannon 完成后,返回终端 A 并使用 CTRL+C 结束诊所节点进程。将分析数据并打印报告。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-08-23
      • 1970-01-01
      • 2016-06-17
      • 2016-12-18
      • 2022-07-17
      • 1970-01-01
      • 2017-03-04
      • 2016-07-21
      相关资源
      最近更新 更多