接口压力测试工具之go-wrk

Posted zlixing

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了接口压力测试工具之go-wrk相关的知识,希望对你有一定的参考价值。

  ​​go-wrk​​​ 是一个用Go语言实现的轻量级的http基准测试工具,类似于​​wrk​​​,本文将简单介绍一下如何使用​​go-wrk​​实现接口的性能(压力)测试。

github地址:​​https://github.com/tsliwowicz/go-wrk​​​

 

安装:

go get github.com/tsliwowicz/go-wrk

 

使用:

Usage: go-wrk  
Options:
-H header line, joined with ; (Default )
-M HTTP method (Default GET)
-T Socket/request timeout in ms (Default 1000)
-body request body string or @filename (Default )
-c Number of goroutines to use (concurrent connections) (Default 10)
-ca CA file to verify peer against (SSL/TLS) (Default )
-cert CA certificate file to verify peer against (SSL/TLS) (Default )
-d Duration of test in seconds (Default 10)
-f Playback file name (Default )
-help Print help (Default false)
-host Host Header (Default )
-http Use HTTP/2 (Default true)
-key Private key file name (SSL/TLS (Default )
-no-c Disable Compression - Prevents sending the "Accept-Encoding: gzip" header (Default false)
-no-ka Disable KeepAlive - prevents re-use of TCP connections between different HTTP requests (Default false)
-redir Allow Redirects (Default false)
-v Print version details (Default false)

 

./go-wrk -c 80 -d 5  http://192.168.1.118:8080/json

持续5秒中, 开启每秒80个并发请求

返回结果:
Running 10s test @ http://192.168.1.118:8080/json
80 goroutine(s) running concurrently
142470 requests in 4.949028953s, 19.57MB read
Requests/sec: 28787.47
Transfer/sec: 3.95MB
Avg Req Time: 0.0347ms
Fastest Request: 0.0340ms
Slowest Request: 0.0421ms
Number of Errors: 0


还有其他参数: -n 10000 就是模拟1w次请求

 


以上是关于接口压力测试工具之go-wrk的主要内容,如果未能解决你的问题,请参考以下文章

研发过程中需要进行的测试

网易cetus读写分离--压力测试

MySQL 之压力测试工具

MySQL 之压力测试工具

Web 性能压力测试工具之 Siege 详解

使用sysbench对mysql压力测试