使用Apache的ab工具进行网站性能测试

来源:互联网 发布:淘宝排名收费 编辑:程序博客网 时间:2024/06/06 03:08

ab 的用法是:ab [options] [http://]hostname[:port]/path

例如:ab -n 5000 -c 200 http://localhost/index.php

上例表示总共访问http://localhost/index.php这个脚本5000次,200并发同时执行。

ab常用参数的介绍:

-n :总共的请求执行数,缺省是1;

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

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

-p:POST时的数据文件

-w: 以HTML表的格式输出结果


执行测试用例:ab -n 1000 -c 100 -w http://localhost/index.php >>c:\1.html

上面的测试用例表示100并发的情况下,共测试访问index.php脚本1000次,并将测试结果保存到c:\1.html文件中。


ab -n 30000 -c 1000 http://127.0.0.1/ >>c:\1.html


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

Benchmarking 127.0.0.1 (be patient)


Server Software:        seo.api163.com
Server Hostname:        127.0.0.1
Server Port:            80

Document Path:          /
Document Length:        91540 bytes

Concurrency Level:      1000
Time taken for tests:   479.745 seconds
Complete requests:      30000
Failed requests:        0
Total transferred:      2749350000 bytes
HTML transferred:       2746200000 bytes
Requests per second:    62.53 [#/sec] (mean)
Time per request:       15991.515 [ms] (mean)
Time per request:       15.992 [ms] (mean, across all concurrent requests)
Transfer rate:          5596.53 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    9  11.0      6     581
Processing:  4762 15893 1705.0  15745   20612
Waiting:      987 4933 2526.8   4481   14142
Total:       4763 15903 1706.1  15753   20650

Percentage of the requests served within a certain time (ms)
  50%  15753
  66%  16154
  75%  16546
  80%  17244
  90%  17885
  95%  18857
  98%  19084
  99%  19183
 100%  20650 (longest request)

这是ApacheBench,2.3版<<修订:美元1706008美元>

版权所有1996 Adam Twiss,宙斯科技有限公司,http://www.zeustech.net/

授权给Apache软件基金会,http://www.apache.org/

标杆127.0.0.1(耐心)

服务器软件:seo.api163.com

服务器主机名:127.0.0.1

服务器端口:80

文档路径:

文件长度:91540字节

并发级别:1000

测试时间:479.745秒

完整请求:30000

失败的请求:0

总计传输:2749350000字节

传输的HTML:2746200000字节

每秒的请求数:62.53 [ # /秒](平均)

每次请求时间:15991.515毫秒(平均值)

每个请求的时间:15.992毫秒(平均,跨越所有并发请求)

传输速率:5596.53 [千字节/秒]收到

连接时间(ms)

最大平均值

连接:0 9 11 6 581

加工:4762、15893、1705、15745、20612

等待:987 4933 2526.8 4481 14142

总计:4763 15903 1706.1 15753 20650

在一定时间内送达请求的百分比(MS)

50% 15753

66% 16154

75% 16546

80% 17244

90% 17885

95% 18857

98% 19084

99% 19183

100% 20650(最长请求)
原创粉丝点击