用apache的ab工具进行压力测试
首页->学习资料->编程语言->php教程->大型网站技术 关键词: 发布时间:2016-10-26 07:31:35 浏览次数:1585

windows下:

http://jingyan.baidu.com/article/e3c78d647a57833c4c85f502.html


linux下,如果没有装apche,先要装一下ab:

测试工具安装(以centos系统为例)yum -y install httpd-tools


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表的格式输出结果



下面是一个完整的测试:


[root@localhost public]# ab -n 100 -c 100 http://www.hu-rong.com
ab: invalid URL
Usage: ab [options] [http[s]://]hostname[:port]/path
Options are:
    -n requests     Number of requests to perform
    -c concurrency  Number of multiple requests to make
    -t timelimit    Seconds to max. wait for responses
    -b windowsize   Size of TCP send/receive buffer, in bytes
    -p postfile     File containing data to POST. Remember also to set -T
    -u putfile      File containing data to PUT. Remember also to set -T
    -T content-type Content-type header for POSTing, eg.
                    'application/x-www-form-urlencoded'
                    Default is 'text/plain'
    -v verbosity    How much troubleshooting info to print
    -w              Print out results in HTML tables
    -i              Use HEAD instead of GET
    -x attributes   String to insert as table attributes
    -y attributes   String to insert as tr attributes
    -z attributes   String to insert as td or th attributes
    -C attribute    Add cookie, eg. 'Apache=1234. (repeatable)
    -H attribute    Add Arbitrary header line, eg. 'Accept-Encoding: gzip'
                    Inserted after all normal header lines. (repeatable)
    -A attribute    Add Basic WWW Authentication, the attributes
                    are a colon separated username and password.
    -P attribute    Add Basic Proxy Authentication, the attributes
                    are a colon separated username and password.
    -X proxy:port   Proxyserver and port number to use
    -V              Print version number and exit
    -k              Use HTTP KeepAlive feature
    -d              Do not show percentiles served table.
    -S              Do not show confidence estimators and warnings.
    -g filename     Output collected data to gnuplot format file.
    -e filename     Output CSV file with percentages served
    -r              Don't exit on socket receive errors.
    -h              Display usage information (this message)
    -Z ciphersuite  Specify SSL/TLS cipher suite (See openssl ciphers)
    -f protocol     Specify SSL/TLS protocol (SSL2, SSL3, TLS1, or ALL)
[root@localhost public]# ab -n 100 -c 100 http://www.hu-rong.com/index.php
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 www.hu-rong.com (be patient).....done


Server Software:        nginx
Server Hostname:        www.hu-rong.com
Server Port:            80

Document Path:          /index.php
Document Length:        21966 bytes

Concurrency Level:      100
Time taken for tests:   7.392 seconds
Complete requests:      100
Failed requests:        0
Write errors:           0
Total transferred:      2357528 bytes
HTML transferred:       2320439 bytes
Requests per second:    13.53 [#/sec] (mean)
Time per request:       7391.820 [ms] (mean)
Time per request:       73.918 [ms] (mean, across all concurrent requests)
Transfer rate:          311.46 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:       11  749 1248.5     96    3037
Processing:    44 2361 1763.3   2064    7151
Waiting:       29  630 595.0    415    3061
Total:        122 3110 2002.9   3629    7234

Percentage of the requests served within a certain time (ms)
  50%   3629
  66%   4245
  75%   4644
  80%   4947
  90%   5532
  95%   6486
  98%   6776
  99%   7234
 100%   7234 (longest request)
[root@localhost public]#

赞:(0)
踩:(0)
相关文章
大型网站及面临的问题及解决方法
网页静态化
thinkphp网页静态化
sphinx全文索引
高并发时表锁与文件锁
海量订单数据存储方法
高并发时商品库存处理方法
高并发测试及系统状态监测
PHP解决抢购、秒杀、抢楼、抽奖等
php多线程例子
热门文章
win7中将文件拷贝到虚拟机linux下
phpexcel设置行高及列宽,背景颜色,
rabbitmq无法启动
intellij idea不显示git push按钮
php7中使用mongodb的aggregate进行
centos7.4 64位下swoole安装及配置
laravel页面静态化的方法
navicate连接mycat报1184错误
单点登录sso原理及php实现方式及de
devops-jenkins容器为pending状态
好评文章
phpexcel设置行高及列宽,背景颜色,
php7中使用mongodb的aggregate进行
intellij idea打开文件所在文件夹
windows下使用MongoDB Compass Com
win7中将文件拷贝到虚拟机linux下
laravel 中悲观锁 & 乐观锁的使用
单点登录sso原理及php实现方式及de
navicate连接mycat报1184错误
rabbitmq无法启动
laravel整合dingo/api方法步骤:jwt
标签
rabbitmq mysql备份 elasticsearch golang swoole
我的项目
【github】www.github.com/hurong241
【码云】gitee.com/hu_rong/projects
【docker hub】hub.docker.com/repositories/hurong241
【packagist】packagist.org/users/hurong241/packages
站点信息
建站时间:2011年
文章数:607篇
浏览数:916013
粤ICP备18028092号-1  微信:hurong241