ab压力测试工具

1 我们可以模拟100个并发用户,对一个页面发送1000个请求

./ab -n1000 -c100 https://www.baidu.com/

其中-n代表请求数,-c代表并发数
ab常用参数的介绍:
-n :总共的请求执行数,缺省是1;

-c: 并发数,缺省是1;

-t:测试所进行的总时间,秒为单位,缺省50000s

-p:POST时的数据文件

-w: 以HTML表的格式输出结果
执行测试用例:ab -n 1000 -c 100 -w http://localhost/index.php >>1.html
上面的测试用例表示100并发的情况下,共测试访问index.php脚本1000次,并将测试结果保存到1.html文件中。

返回结果:

首先是apache的版本信息

This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking vm1.jianfeng.com (be patient)

Server Software: Apache/2.2.19 ##apache版本
Server Hostname: vm1.jianfeng.com ##请求的机子
Server Port: 80 ##请求端口

Document Path: /a.html
Document Length: 25 bytes ##页面长度

Concurrency Level: 100 ##并发数
Time taken for tests: 0.273 seconds ##共使用了多少时间
Complete requests: 1000 ##请求数
Failed requests: 0 ##失败请求
Write errors: 0
Total transferred: 275000 bytes ##总共传输字节数,包含http的头信息等
HTML transferred: 25000 bytes ##html字节数,实际的页面传递字节数
Requests per second: 3661.60 [#/sec] (mean) ##每秒多少请求,这个是非常重要的参数数值,服务器的吞吐量
Time per request: 27.310 [ms] (mean) ##用户平均请求等待时间
Time per request: 0.273 [ms] (mean, across all concurrent requests) ##服务器平均处理时间,也就是服务器吞吐量的倒数
Transfer rate: 983.34 [Kbytes/sec] received ##每秒获取的数据长度

Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 1 2.3 0 16
Processing: 6 25 3.2 25 32
Waiting: 5 24 3.2 25 32
Total: 6 25 4.0 25 48

Percentage of the requests served within a certain time (ms)
50% 25 ## 50%的请求在25ms内返回
66% 26 ## 60%的请求在26ms内返回
75% 26
80% 26
90% 27
95% 31
98% 38
99% 43
100% 48 (longest request)

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智...
    卡卡罗2017阅读 135,534评论 19 139
  • 原文:https://www.fanhaobai.com/2016/02/ab.html ab(ApacheBen...
    Howborn阅读 4,390评论 0 1
  • 1、附带cookie 先构建个“已登录”的会话,把标识这个会话的Cookie值(Session ID)记下来。如果...
    zshanjun阅读 3,459评论 0 0
  • 当你使用PHP(或其他编程语言)完成一个web程序的开发,并且web程序在Apache服务器上正常运行的时候,你有...
    零一间阅读 19,825评论 0 14
  • 写在前面 在学习ab工具之前,我们需了解几个关于压力测试的概念 吞吐率(Requests per second)概...
    橙子酱阅读 241,336评论 13 190