本文主要是介绍soul从入门到进阶06——运行soul-examples-dubbo,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
前面我们初步尝试了soul网关的http协议相关的功能。这篇我们来看一下 dubbo协议的功能。
1. 启动soul-admin 和 soul-bootstrap
省略 可参考 soul从入门到进阶01——soul网关初体验
2. 启动 soul-example-dubbo
- 打开命令行
cd soul-examples
cd soul-examples-dubbo
可以看到分别是apache dubboe的example和 alibaba dubbo的example
- 进入
soul-examples-apache-dubbo-service
这个模块 - 运行
TestApacheDubboApplication
- 发现报错了,显示
zookeeper
没有连接 - 下载一个
zookeeper
,注意 如果是初次使用,需要将conf文件夹下的zoo_sample.cfg
复制为名为zoo.cfg
的文件,否则会报以下错误。
pache-zookeeper-3.6.2-bin/bin/../conf/zoo.cfg: No such file or directory
- 此时再次启动
TestApacheDubboApplication
3 查看soul-admin
- 如下图所示,dubbo这个插件里多了一个选择器。选择器里面有很多规则。
4. 通过http访问dubbo
- 在 postman 请求
http://localhost:9195/dubbo/findAll
{"code": 200,"message": "Access to success!","data": {"name": "hello world Soul Apache, findAll","id": "-275502741"}
}
- 发现bootstrap 打印了如下日志
2021-01-21 00:13:35.517 INFO 23633 --- [-work-threads-1] o.d.soul.plugin.base.AbstractSoulPlugin : dubbo selector success match , selector name :/dubbo
2021-01-21 00:13:35.518 INFO 23633 --- [-work-threads-1] o.d.soul.plugin.base.AbstractSoulPlugin : dubbo selector success match , selector name :/dubbo/findAll
5. 修改规则
- 在soul-admin 将 【dubbo插件】——【dubbo选择器】——【/dubbo/findAll 规则】关闭。
- 再次请求
http://localhost:9195/dubbo/findAll
- 响应结果如下 ,没有这条规则,就不能访问
{"code": -102,"message": "Rule not found!","data": null
}
6. 压测一下
wrk -t16 -c200 -d30s http://localhost:9195/dubbo/findAll
Running 30s test @ http://localhost:9195/dubbo/findAll16 threads and 200 connectionsThread Stats Avg Stdev Max +/- StdevLatency 17.82ms 24.68ms 498.22ms 93.66%Req/Sec 829.79 268.27 1.51k 69.90%379644 requests in 30.09s, 66.61MB readSocket errors: connect 0, read 157, write 0, timeout 0
Requests/sec: 12616.85
Transfer/sec: 2.21MB
Running 30s test @ http://localhost:9195/dubbo/findAll16 threads and 200 connectionsThread Stats Avg Stdev Max +/- StdevLatency 13.00ms 11.01ms 121.05ms 74.91%Req/Sec 1.05k 142.75 1.52k 74.88%500028 requests in 30.03s, 87.73MB readSocket errors: connect 0, read 34, write 0, timeout 0
Requests/sec: 16653.62
Transfer/sec: 2.92MB
Running 30s test @ http://localhost:9195/dubbo/findAll16 threads and 200 connectionsThread Stats Avg Stdev Max +/- StdevLatency 29.02ms 38.88ms 245.86ms 87.01%Req/Sec 710.10 181.88 1.43k 72.27%339633 requests in 30.06s, 59.59MB readSocket errors: connect 0, read 44, write 0, timeout 0
Requests/sec: 11298.65
Transfer/sec: 1.98MB
发现qps在1.2w左右。
采用 压测soul网关 中的办法 将soul-bootstrap 的日志级别调整为warn再次压测
结果如下
Running 30s test @ http://localhost:9195/dubbo/findAll16 threads and 200 connectionsThread Stats Avg Stdev Max +/- StdevLatency 15.63ms 21.21ms 391.96ms 91.58%Req/Sec 0.96k 275.19 1.86k 72.45%453131 requests in 30.04s, 79.51MB readSocket errors: connect 0, read 167, write 0, timeout 0
Requests/sec: 15082.54
Transfer/sec: 2.65MB
Running 30s test @ http://localhost:9195/dubbo/findAll16 threads and 200 connectionsThread Stats Avg Stdev Max +/- StdevLatency 13.16ms 14.72ms 81.69ms 84.26%Req/Sec 1.34k 185.92 2.12k 69.48%641716 requests in 30.02s, 112.59MB readSocket errors: connect 0, read 53, write 0, timeout 0
Requests/sec: 21376.63
Transfer/sec: 3.75MB
Running 30s test @ http://localhost:9195/dubbo/findAll16 threads and 200 connectionsThread Stats Avg Stdev Max +/- StdevLatency 20.25ms 27.69ms 136.29ms 83.67%Req/Sec 1.32k 263.94 2.43k 69.90%630119 requests in 30.02s, 110.56MB readSocket errors: connect 0, read 51, write 0, timeout 0
Requests/sec: 20987.25
Transfer/sec: 3.68MB
性能明显提升了,可以达到2w的qps
这篇关于soul从入门到进阶06——运行soul-examples-dubbo的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!