压力测试Apache

在做类似商城秒杀系统的同事都知道要在支持高并发,高可用的环境下进行多次的压力测试来防止自己的项目结构被高额的点击量击穿,导致商品超卖等损失

介绍一款简单的软件 xampp   

xam里带了Apache服务器   

Apache服务器自带有一个叫AB(ApacheBench)的工具,可以对服务器进行负载测试

 

装xampp软件

 

进入 c:/xampp/apache/bin

 

基本用法:

 

ab  -n 全部请求数 -c 并发数测试url

 

注:可以将ab.exe 加入系统环境变量;或直接切换置 ab 目录执行。如: C:\Windows\System32> cd C:\xampp\apache\bin

  

更多参数:

-n  requests     全部请求数

 

-c  concurrency  并发数

 

-t  timelimit     最传等待回应时间

 

-p  postfile      POST数据文件

 

-T  content-type  POST Content-type

 

-v  verbosity     Howmuch troubleshooting info to print

 

-w              Print outresults 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    加入cookie, eg.'Apache=1234. (repeatable)

 

-H  attribute    加入http, eg.'Accept-Encoding: gzip'

 

                Inserted after all normalheader lines. (repeatable)

 

-A  attribute    http验证,分隔传递用户名及密码

 

-P  attribute    Add Basic Proxy Authentication, theattributes

 

                are a colon separated usernameand password.

 

-X  proxy:port   代理服务器

 

-V              查看ab版本

 

-k              Use HTTPKeepAlive feature

 

-d              Do not showpercentiles served table.

 

-S              Do not showconfidence estimators and warnings.

 

-g  filename     Output collected data to gnuplot formatfile.

 

-e  filename     Output CSV file with percentages served

 

-h              Display usageinformation (this message)

posted @ 2019-04-11 21:31  smileOHH  阅读(280)  评论(0编辑  收藏  举报