Jer*_*oen 5 node.js socket.io docker artillery
在对我的 node.js socket.io 应用程序进行性能测试时,它似乎无法处理所需数量的并发 websocket 请求。
我正在使用以下规范在 Docker 环境中测试应用程序:
CPU:2 内存:4 GB
该应用程序被精简到只接受带有 socket.io + express.js 的 websocket 连接的最低限度。
我在artillery.io的帮助下进行了测试,测试场景是:
config:
target: "http://127.0.0.1:5000"
phases:
- duration: 100
arrivalRate: 20
scenarios:
- engine: "socketio"
flow:
- emit:
channel: "echo"
data: "hello"
- think: 50
Run Code Online (Sandbox Code Playgroud)
报告:
Summary report @ 16:54:31(+0200) 2018-07-30
Scenarios launched: 2000
Scenarios completed: 101
Requests completed: 560
RPS sent: 6.4
Request latency:
min: 0.1
max: 3
median: 0.2
p95: 0.5
p99: 1.4
Scenario counts:
0: 2000 (100%)
Codes:
0: 560
Errors:
Error: xhr poll error: 1070
timeout: 829
Run Code Online (Sandbox Code Playgroud)
所以我收到了很多 xhr 轮询错误。当我监控 CPU + mem 统计信息时,CPU 的最高值仅为43,25%。内存只会高达4%。
即使我在100秒的时间跨度内将我的测试更改为20的到达率,我仍然会遇到 XHR 轮询错误。
那么这些测试数字是否超出了具有此规范的 nodejs + socket.io 的能力,还是其他东西无法按预期工作?也许是 docker 环境或 Artillery 软件?
任何帮助或建议将不胜感激!
旁注:已经研究了用于扩展的 nodejs 集群,但希望首先从一个进程中获得最大收益。
更新 1
在使用此处找到的 websocket 压力测试脚本进行更多测试后:https ://gist.github.com/redism/11283852 当我使用高于 50 的到达率或想要建立更多连接时,似乎我达到了某种限制 + /- 1900 年。
直到 1900 个连接,几乎每个连接都建立起来,但在这个数字之后,XHR 轮询错误呈指数增长。
docker 容器仍然没有高 CPU 或内存值。
XHR 轮询错误详细说明:
Error: xhr poll error
at XHR.Transport.onError (D:\xxx\xxx\api\node_modules\engine.io-client\lib\transport.js:64:13)
at Request.<anonymous> (D:\xxx\xxx\api\node_modules\engine.io-client\lib\transports\polling-xhr.js:128:10)
at Request.Emitter.emit (D:\xxx\xxx\api\node_modules\component-emitter\index.js:133:20)
at Request.onError (D:\xxx\xxx\api\node_modules\engine.io-client\lib\transports\polling-xhr.js:309:8)
at Timeout._onTimeout (D:\xxx\xxx\api\node_modules\engine.io-client\lib\transports\polling-xhr.js:256:18)
at ontimeout (timers.js:475:11)
at tryOnTimeout (timers.js:310:5)
at Timer.listOnTimeout (timers.js:270:5) type: 'TransportError', description: 503
Run Code Online (Sandbox Code Playgroud)
更新 2
在炮兵测试中将传输更改为“websocket”可提供更好的性能。
测试用例:
config:
target: "http://127.0.0.1:5000"
socketio:
transports: ["websocket"]
phases:
- duration: 20
arrivalRate: 200
scenarios:
- engine: "socketio"
flow:
- emit:
channel: "echo"
data: "hello"
- think: 50
Run Code Online (Sandbox Code Playgroud)
结果:到达率不再是问题,但我在 2020 年达到了某种限制。之后它会给出“Websocket错误”。
那么这是 Windows 10 的限制吗?你能改变它吗?这是限制的原因,测试与长轮询执行如此糟糕
| 归档时间: |
|
| 查看次数: |
1605 次 |
| 最近记录: |