内容简介:现在grpc的压测工具很少,比http的压测工具少太多了,好像还没有一个“公认”的压测工具,在github中搜索“grpc benchmark”,
说明
现在grpc的压测 工具 很少,比http的压测工具少太多了,好像还没有一个“公认”的压测工具,在github中搜索“grpc benchmark”, bojand/ghz 排在比较靠前的位置,文档也比较齐全整洁: Simple gRPC benchmarking and load testing tool 。也有文章分享了用 Locust进行grpc压测 的方法。
相关笔记:
Go语言实现grpc server和grpc client,用protobuf格式的消息通信(GRPC)
下载
编译源代码遇到找不到包的问题,没时间进行折腾,对于工具还秉持“能用就行”的态度,遇到需要通过修改源码解决的问题,或者有闲暇,再深入研究学习一下它们的实现。
好在ghz的release页面提供了已经编译好的可执行文件,直接下载使用好了: bojand/ghz release 。
使用
ghz的一个好处是直接传入.proto文件就可以压测了,不需要根据grpc的.proto文件生成单独的压测程序。
例如压测Grpc项目中的例子helloworld:
./ghz -insecure \
-proto ./helloworld.proto \
-call helloworld.Greeter.SayHello \
-d '{"name":"Joe"}' \
-c 10 \
-n 100000 \
10.10.64.58:50051
压测输出如下:
Summary: Count: 100000 Total: 8.07 s Slowest: 41.88 ms Fastest: 0.54 ms Average: 7.87 ms Requests/sec: 12387.61 Response time histogram: 0.538 [1] | 4.672 [22943] |∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎ 8.806 [46907] |∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎ 12.940 [19671] |∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎ 17.074 [5965] |∎∎∎∎∎ 21.208 [2077] |∎∎ 25.342 [1094] |∎ 29.476 [725] |∎ 33.610 [381] | 37.743 [146] | 41.877 [90] | Latency distribution: 10% in 3.70 ms 25% in 4.81 ms 50% in 6.65 ms 75% in 9.58 ms 90% in 13.15 ms 95% in 16.56 ms 99% in 27.01 ms Status code distribution: [OK] 100000 responses
官网上有更多的例子 Examples 。
注意
参数 -c 指定并发请求数:
-c Number of requests to run concurrently.
Total number of requests cannot be smaller than the concurrency level. Default is 50.
压测时观察连接情况,发现无论-c指定的参数是多少,都只有建立一个tcp连接,-c所指的并发似乎指定是并发的往一个grpc连接中发请求,而不是模拟多个client。
参考
以上所述就是小编给大家介绍的《Grpc性能压测方法:用ghz进行压测》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!
猜你喜欢:- Jmeter进行Web站点性能测试
- 60,000 毫秒内对 Linux 进行性能诊断
- 用 dotTrace 进行性能分析时,各种不同性能分析选项的含义和用途
- 对node工程进行压力测试与性能分析
- 闪存缓存可提高应用程序性能,但需要进行平衡
- 高效进行Oracle日常巡检:数据库性能与安全检查
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
Mathematica Cookbook
Sal Mangano / O'Reilly Media / 2009 / GBP 51.99
As the leading software application for symbolic mathematics, Mathematica is standard in many environments that rely on math, such as science, engineering, financial analysis, software development, an......一起来看看 《Mathematica Cookbook》 这本书的介绍吧!
XML 在线格式化
在线 XML 格式化压缩工具
RGB HSV 转换
RGB HSV 互转工具