社区微信群开通啦,扫一扫抢先加入社区官方微信群
社区微信群
mqtt 相关文章分类:https://blog.csdn.net/freewebsys/article/category/8677221
本文的原文连接是: https://blog.csdn.net/freewebsys/article/details/87784882
未经博主允许不得转载。
博主地址是:http://blog.csdn.net/freewebsys
使用 golang 编写的 mqtt 的基准测试工具。
有两个github 项目:
使用的是这个,进行基准测试,带vendor 文件夹。展示的结果好看些。
https://github.com/krylovsk/mqtt-benchmark
一个日本人写的项目,没有 vendor,结果没有格式化。
https://github.com/takanorig/mqtt-bench
下载
https://github.com/krylovsk/mqtt-benchmark
里面少了一个 websocket的包。需要使用 vendor 工具补齐。
go get golang.org/x/net/websocket
#安装
go get -u github.com/kardianos/govendor
go install github.com/kardianos/govendor
进入工程目录
#初始化
govendor init
#加入本地 vendor目录当中。
govendor add +external
#查看生成列表。
govendor list
查看list 安装
$ govendor list
pv github.com/GaryBoone/GoStats/descriptive_statistics_demo
pv github.com/GaryBoone/GoStats/regression_demo
v github.com/GaryBoone/GoStats/stats
v github.com/eclipse/paho.mqtt.golang
v github.com/eclipse/paho.mqtt.golang/packets
pv github.com/eclipse/paho.mqtt.golang/samples
v golang.org/x/net/websocket
pl github.com/krylovsk/mqtt-benchmark
m GoStats/stats
运行测试:
./mqtt-benchmark -broker="tcp://localhost:1883" -clients=300 -count=100 -size=10 -quiet=true -topic="/test"
结果:
......
======= CLIENT 6 =======
Ratio: 1.000 (100/100)
Runtime (s): 0.041
Msg time min (ms): 0.110
Msg time max (ms): 0.760
Msg time mean (ms): 0.291
Msg time std (ms): 0.107
Bandwidth (msg/sec): 2410.829
======= CLIENT 1 =======
Ratio: 1.000 (100/100)
Runtime (s): 0.043
Msg time min (ms): 0.133
Msg time max (ms): 0.607
Msg time mean (ms): 0.287
Msg time std (ms): 0.102
Bandwidth (msg/sec): 2352.793
======= CLIENT 3 =======
Ratio: 1.000 (100/100)
Runtime (s): 0.043
Msg time min (ms): 0.102
Msg time max (ms): 3.549
Msg time mean (ms): 0.306
Msg time std (ms): 0.348
Bandwidth (msg/sec): 2308.455
========= TOTAL (10) =========
Total Ratio: 1.000 (1000/1000)
Total Runtime (sec): 0.044
Average Runtime (sec): 0.041
Msg time min (ms): 0.102
Msg time max (ms): 3.549
Msg time mean mean (ms): 0.289
Msg time mean std (ms): 0.007
Average Bandwidth (msg/sec): 2421.400
Total Bandwidth (msg/sec): 24214.000
使用 mqtt-benchmark 进行基准测试。
可以很方便的测试看看负载压力咋样。然后对比进行优化。修改jvm 参数。增服务器负载。
mqtt 已经是非常的方便了。相关的项目都是很多了。非常完备。
本文的原文连接是:
https://blog.csdn.net/freewebsys/article/details/87784882
如果觉得我的文章对您有用,请随意打赏。你的支持将鼓励我继续创作!