
 主 题 
今天突然想之前写好的博客接口进行一下压力测试,搜索一番之后发现工具很多,因为最近在学go终于选了go语言版本的wrk,go-wrk来进行测试。
安装go-wrk
        
            
            
              language
              
              
              
            
          
          go install github.com/tsliwowicz/go-wrk@latest使用
            
            
              language
              
              
              
            
          
          go-wrk [参数] url
# url(http链接)常用参数说明
            
            
              language
              
              
              
            
          
             Usage: go-wrk <options> <url>
   Options:
    -H       自定义请求头
    -M       http请求方式 默认为get
    -T       请求超时时间(毫秒)默认1000
    -body    请求体(字符串)
    -c       使用的goroutine协程数 默认10
    -ca      SSL/TLS 验证文件
    -cert    CA 验证文件
    -d       测试持续时间
    -help    打印帮助 (Default false)
    -host    主机 (Default )
    -http    使用 HTTP/2 (Default true)执行测试
            
            
              language
              
              
              
            
          
          go-wrk -c 80 -d 5 http://localhost:9600/api/v1/third/gushici测试结果
            
            
              language
              
              
              
            
          
          # go-wrk -c 80 -d 5 http://localhost:9600/api/v1/third/gushici
# 直接请求ip地址接口结果如下
Running 5s test @ http://localhost:9600/api/v1/third/gushici
  80 goroutine(s) running concurrently
12797 requests in 5.010112438s, 6.94MB read
Requests/sec:           2554.23
Transfer/sec:           1.39MB
Avg Req Time:           31.320543ms
Fastest Request:        25.5602ms
Slowest Request:        134.7137ms
Number of Errors:       0
#请求域名结果如下
#go-wrk -c 80 -d 5 https://jiang-xia.top/x-zone/api/v1/third/gushici
210 requests in 235.165583ms, 126.05KB read
Requests/sec:           892.99
Transfer/sec:           536.02KB
Avg Req Time:           89.586889ms
Fastest Request:        27.2799ms
Slowest Request:        3.6713208s
Number of Errors:       12140结论
- nginx配置限制之后,还是挺有用的,并发请求过多的话直接请求失败了。
- 博客并发请求两还是不错的

全部评论(1)