0


并发测试工具

这里写目录标题

并发测试工具

ab 工具

ab

is a tool for benchmarking your Apache Hypertext Transfer Protocol (HTTP) server. It is designed to give you an impression of how your current Apache installation performs. This especially shows you how many requests per second your Apache installation is capable of serving.

Doc: Apache HTTP server benchmarking tool

使用

输入命令:

ab -n100-c10 http://test.com/

其中

-n

表示请求数,

-c

表示并发数。

上面的命令运行完毕后就出来测试报告了。

  • 完整测试报告

这段展示的是 web 服务器的信息, 可以看到服务器采用的是

nginx

, 域名是 xx, 端口是 xx

  • 服务器信息

这段是关于请求的文档的相关信息, 所在位置 “/”, 文档的大小为

338436 bytes

(此为 http 响应的正文长度)

  • 文档信息

这段展示了压力测试的几个重要指标

重要指标

Concurrency Level: 100 //并发请求数
Time taken for tests: 50.872 seconds //整个测试持续的时间
Complete requests: 1000 //完成的请求数
Failed requests: 0 //失败的请求数

Total transferred: 13701482 bytes //整个场景中的网络传输量
HTML transferred: 13197000 bytes //整个场景中的 HTML 内容传输量

Requests per second: 19.66 [#/sec] (mean) //吞吐率, 大家最关心的指标之一, 相当于 LR 中的每秒事务数, 后面括号中的 mean 表示这是一个平均值
Time per request: 5087.180 [ms] (mean) //用户平均请求等待时间, 大家最关心的指标之二, 相当于 LR 中的平均事务响应时间, 后面括号中的 mean 表示这是一个平均值
Time per request: 50.872 [ms] (mean, across all concurrent requests) //服务器平均请求处理时间, 大家最关心的指标之三

Transfer rate: 263.02 [Kbytes/sec] received //平均每秒网络上的流量, 可以帮助排除是否存在网络流量过大导致响应时间延长的问题

这段表示网络上消耗的时间的分解

网络消耗时间

这段是每个请求处理时间的分布情况, 50%的处理时间在 4930ms 内, 66%的处理时间在 5008ms 内。…, 重要的是看 90%的处理时间。

响应情况

  • 关于登录的问题

有时候进行压力测试需要用户登录, 怎么办?
请参考以下步骤:

先用账户和密码登录后, 用开发者工具找到标识这个会话的 Cookie 值(Session ID)记下来

如果只用到一个 Cookie, 那么只需键入命令:

ab -n 100 -C key=value http://test.com/

如果需要多个 Cookie, 就直接设 Header:

ab -n100-H"Cookie: Key1=Value1; Key2=Value2" http://test.com/
  • 总结

总的来说 ab 工具 ab 小巧简单, 上手学习较快, 可以提供需要的基本性能指标, 但是没有图形化结果, 不能监控。因此 ab 工具可以用作临时紧急任务和简单测试。

同类型的压力测试工具还有:

webbench

siege

http_load

安装

  • How to install just ab (apachebench) on Debian or Ubuntu

Running

nginx

(or

lighttpd

, or any other web server) but still want to make use of Apache’s useful

ab

(apachebench) benchmarking tool?

apt-getinstall apache2-utils

…should do it.

标签: test benchmark apache

本文转载自: https://blog.csdn.net/wan212000/article/details/128500930
版权归原作者 云满笔记 所有, 如有侵权,请联系我们删除。

“并发测试工具”的评论:

还没有评论