BatonHTTP 负载测试工具

联合创作 · 2023-10-01 19:55

Baton 是一个用 Go 编写的 HTTP 负载测试工具,目前支持 GET、POST、PUT 和 DELETE 请求。

安装

$ go get -u github.com/americanexpress/baton

使用

目前支持以下选项

  -b string
    	Body (use instead of -f)
  -c int
    	Number of concurrent requests (default 1)
  -f string
    	File path to file to be used as the body (use instead of -b)
  -i	Ignore TLS/SSL certificate validation
  -m string
    	HTTP Method (GET,POST,PUT,DELETE) (default "GET")
  -o	Supress output, no results will be printed to stdout
  -r int
    	Number of requests (use instead of -t) (default 1)
  -t int
    	Duration of testing in seconds (use instead of -r)
  -u string
    	URL to run against
  -w int
    	Number of seconds to wait before running test
  -z string
    	Read requests from a file

下面是使用 10 个终端发送 200,000 个请求的基本示例:

 

$ baton -u http://localhost:8080/test -c 10 -r 200000

可以指定发送请求的时间(以秒为单位),而不是请求的数量,Baton 会等收到所有响应之后才报告结果。

请求文件

如果从 -z filename指定加载请求的文件,文件必须为 CSV 格式。

<method>,<url>,[<body>],[<header-key>:<header-value>, ...]
...

可以在末尾有一个或多个标题,用 隔开,比如:

POST,http://localhost:8888,body,Accept: application/xml,Content-type: Secret
GET,http://localhost:8888,,,

输出示例

====================== Results ======================
Total requests:                               1254155
Time taken to complete requests:        10.046739294s
Requests per second:                           124832
Max response time (ms):                           440
Min response time (ms):                            55
Avg response time (ms):                        156.70
===================== Breakdown =====================
Number of connection errors:                        0
Number of 1xx responses:                            0
Number of 2xx responses:                      1254155
Number of 3xx responses:                            0
Number of 4xx responses:                            0
Number of 5xx responses:                            0
=====================================================
浏览 6
点赞
评论
收藏
分享

手机扫一扫分享

编辑 分享
举报
评论
图片
表情
推荐
点赞
评论
收藏
分享

手机扫一扫分享

编辑 分享
举报