TypechoJoeTheme

主机评测

VPS教程

专注云服务器评测和优惠码发布

开源HTTP压力测试_

2021-01-17
/
0 评论
/
2,339 阅读
/
百度已收录
01/17

hey是一款使用Golang开发的HTTP压力测试工具,可作为ApacheBench (ab)替代品,在之前的文章中《socat与Brook端口转发测试对比哪个更好?》有提到hey这个工具,这篇文章来详细说明下hey的安装和使用。

安装hey

以下使用Linux 64位系统,如果您是其它操作系统,请自行前往hey项目地址下载对应客户端。

作者已经提供编译好的二进制包,可直接下载使用:

  1. #下载hey
  2. wget https://hey-release.s3.us-east-2.amazonaws.com/hey_linux_amd64
  3. #赋予执行权限
  4. chmod +x hey_linux_amd64
  5. #移动文件到sbin目录
  6. mv hey_linux_amd64 /usr/sbin/hey

如果是其它操作系统,请对号入座:

hey的使用

输入hey -h查看帮助信息:

  1. flag needs an argument: -h
  2. Usage: hey [options...] <url>
  3. Options:
  4. -n Number of requests to run. Default is 200.
  5. -c Number of workers to run concurrently. Total number of requests cannot
  6. be smaller than the concurrency level. Default is 50.
  7. -q Rate limit, in queries per second (QPS) per worker. Default is no rate limit.
  8. -z Duration of application to send requests. When duration is reached,
  9. application stops and exits. If duration is specified, n is ignored.
  10. Examples: -z 10s -z 3m.
  11. -o Output type. If none provided, a summary is printed.
  12. "csv" is the only supported alternative. Dumps the response
  13. metrics in comma-separated values format.
  14. -m HTTP method, one of GET, POST, PUT, DELETE, HEAD, OPTIONS.
  15. -H Custom HTTP header. You can specify as many as needed by repeating the flag.
  16. For example, -H "Accept: text/html" -H "Content-Type: application/xml" .
  17. -t Timeout for each request in seconds. Default is 20, use 0 for infinite.
  18. -A HTTP Accept header.
  19. -d HTTP request body.
  20. -D HTTP request body from file. For example, /home/user/file.txt or ./file.txt.
  21. -T Content-type, defaults to "text/html".
  22. -a Basic authentication, username:password.
  23. -x HTTP Proxy address as host:port.
  24. -h2 Enable HTTP/2.
  25. -host HTTP Host header.
  26. -disable-compression Disable compression.
  27. -disable-keepalive Disable keep-alive, prevents re-use of TCP
  28. connections between different HTTP requests.
  29. -disable-redirects Disable following of HTTP redirects
  30. -cpus Number of used cpu cores.
  31. (default for current machine is 2 cores)

举个例子:

  1. hey -n 10000 -c 100 -m GET https://www.qq.com/
  • -n:请求总数
  • -c:客户端连接数
  • -m:请求方法,比如GET/POST

上面例子的含义就是对https://www.qq.com/发起100个GET并发请求,请求总数为10000个,执行完毕后hey还会打印统计信息,如下。

  1. Summary:
  2. Total: 9.9769 secs
  3. Slowest: 0.3740 secs
  4. Fastest: 0.0350 secs
  5. Average: 0.0971 secs
  6. Requests/sec: 1002.3120
  7. Response time histogram:
  8. 0.035 [1] |
  9. 0.069 [894] |■■■■■■
  10. 0.103 [6193] |■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
  11. 0.137 [2158] |■■■■■■■■■■■■■■
  12. 0.171 [464] |■■■
  13. 0.205 [118] |■
  14. 0.238 [84] |■
  15. 0.272 [56] |
  16. 0.306 [29] |
  17. 0.340 [2] |
  18. 0.374 [1] |
  19. Latency distribution:
  20. 10% in 0.0702 secs
  21. 25% in 0.0802 secs
  22. 50% in 0.0917 secs
  23. 75% in 0.1056 secs
  24. 90% in 0.1266 secs
  25. 95% in 0.1510 secs
  26. 99% in 0.2334 secs
  27. Details (average, fastest, slowest):
  28. DNS+dialup: 0.0016 secs, 0.0350 secs, 0.3740 secs
  29. DNS-lookup: 0.0008 secs, 0.0000 secs, 0.1045 secs
  30. req write: 0.0001 secs, 0.0000 secs, 0.0716 secs
  31. resp wait: 0.0896 secs, 0.0320 secs, 0.2326 secs
  32. resp read: 0.0054 secs, 0.0014 secs, 0.1429 secs
  33. Status code distribution:
  34. [200] 10000 responses

更多用法请自行执行hey -h查看帮助使用。

最后

hey可以很方便的对网站进行压测,并返回详细统计结果。另外压测工具会对服务器造成一定压力,相当于对网站发起CC攻击,因此请勿滥用。

hey项目地址:https://github.com/rakyll/hey

http压力测试hey
朗读

赞 · 1
赞赏
感谢您的支持,我会继续努力哒!
打开手机扫一扫,即可进行打赏哦!
版权属于:

主机评测

本文链接:

https://www.zjpc.cc/399.html(转载时请注明本文出处及文章链接)

评论 (0)
  • OωO
  • |´・ω・)ノ
  • ヾ(≧∇≦*)ゝ
  • (☆ω☆)
  • (╯‵□′)╯︵┴─┴
  •  ̄﹃ ̄
  • (/ω\)
  • ∠( ᐛ 」∠)_
  • (๑•̀ㅁ•́ฅ)
  • →_→
  • ୧(๑•̀⌄•́๑)૭
  • ٩(ˊᗜˋ*)و
  • (ノ°ο°)ノ
  • (´இ皿இ`)
  • ⌇●﹏●⌇
  • (ฅ´ω`ฅ)
  • (╯°A°)╯︵○○○
  • φ( ̄∇ ̄o)
  • ヾ(´・ ・`。)ノ"
  • ( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
  • (ó﹏ò。)
  • Σ(っ °Д °;)っ
  • ( ,,´・ω・)ノ"(´っω・`。)
  • ╮(╯▽╰)╭
  • o(*////▽////*)q
  • >﹏<
  • ( ๑´•ω•) "(ㆆᴗㆆ)
  • (。•ˇ‸ˇ•。)
  • 泡泡
  • 阿鲁
  • 颜文字