服务器负载太大而影响程序效率也是很常见的,Apache服务器自带有一个叫AB(ApacheBench)的工具,可以对服务器进行负载测试

同时美多商城的秒杀功能也会被高负载影响,从而导致超卖现象

安装xampp软件

进入 c:/xampp/apache/bin

基本用法:

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

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

更为详细操作

------------------------------------------------------------------------------------------------

C:\xampp\apache\bin>ab-n 100 -c 10 http://www.abc.com/index.html

This is ApacheBench, Version 2.0.40-dev<$Revision: 1.146 $> apache-2.0

Copyright 1996 Adam Twiss, Zeus TechnologyLtd, http://www.zeustech.NET/

Copyright 2006 The Apache SoftwareFoundation, http://www.apache.org/

Benchmarking www.abc.com (bepatient).....done

Server Software:        Apache

Server Hostname:       www.abc.com

Server Port:            80

Document Path:          /index.html

Document Length:        17784 bytes     #请求文档大小

Concurrency Level:      10              #并发数

Time taken for tests:   11.898681 seconds    #全部请求完成耗时

Complete requests:      100            #全部请求数

Failed requests:        0

Write errors:           0

Total transferred:      1805900 bytes      #总传输大小

HTML transferred:       1778400 bytes

Requests per second:    8.40 [#/sec] (mean)    #每秒请求数(平均)

Time per request:       1189.868 [ms] (mean)  #每次并发请求时间(所有并发)

Time per request:       118.987 [ms] (mean, across all concurrentrequests

Transfer rate:          148.17 [Kbytes/sec] received    #传输速率

Connection Times (ms)           #连接时间

min mean[+/-sd]  median(中位值)  max

Connect: (#连接)     59   73  11.9     72     132

Processing: (#处理)    86   998538.7     938   2288

Waiting: (#等待)     63   135 106.8     94    663

Total:                 155  1072540.6    1004   2362

在一定比例的请求服务时间

50%   1004

66%   1260

75%   1452

80%   1492

90%   1923

95%   2078

98%   2352

99%   2362

100%  2362 (longest request)

----------------------------------------------------------------------------------------------------------------------------

#整个场景中所有请求的响应情况,在场景中每个请求都有一个响应时间,其中

50%的用户响应时间小于1104毫秒,

80%的用户响应时间小于1492毫秒,

最大的响应时间小于2362毫秒。

备:由于对发请求,cpu实际上并不是同时处理的,而是按照每个请求获得的时间片逐个轮转处理的,所以,基本上第一个Timeper request时间约等于第二个Timeper request时间乘以并发请求数。

其它参数:

-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)

AB(ApacheBench)工具 -- 压力测试的更多相关文章

  1. 使用ab 进行并发压力测试

    使用ab 进行并发压力测试 - 参与商 - 博客园 https://www.cnblogs.com/shenshangzz/p/8340640.html 使用ab 进行并发压力测试   ab全称为:a ...

  2. Apache ab并发负载压力测试(python+django+mysql+apache)

    如标题,大家都知道秒杀中存在高并发使库存骤然为0,但在我们个人PC或小区域内是模拟不出这样的情景 现在利用 Apache ab并发负载压力测试 1,数据库建入库存字段并映射模型 2,view编写脚本 ...

  3. ab并发负载压力测试

    一.ab 0.安装ab压力测试软件 [root@a2 conf]# yum install httpd-tools -y #查看版本 [root@a2 conf]# ab -V This is Apa ...

  4. windows Apache ab安装及压力测试

    一:安装 ab是Apache自带的网站压力测试工具.使用起来非常的简单和方便.不仅仅是可以Apache服务器进行网站访问压力测试,还可以对其他类型的服务器进行压力测试.比如nginx,tomcat,I ...

  5. Apache ab并发负载压力测试

    由于现在网站都需要能够承受高并发要求的能力,所以当我们写完代码后,如果需要上线,最好都经过压力测试后,这样比较好 运行: 在Windows系统下,打开cmd命令行窗口,定位到apache安装目录的bi ...

  6. apache的ab命令做压力测试

    1. 最基本的关心两个选项 -c -n 例: ./ab -c 100 -n 10000 http://127.0.0.1/index.php -c 100 即:每次并发100个-n 10000 即: ...

  7. ab命令执行压力测试

    ab是Apache超文本传输协议(HTTP)的性能测试工具:设计意图是描绘当前所安装的Apache的执行性能,主要是显示你安装的Apache每秒可以处理多少个请求:ab不仅仅能进行基于apache服务 ...

  8. Apache服务器下使用 ab 命令进行压力测试

    ab是Apache超文本传输协议(HTTP)的性能测试工具. 其设计意图是描绘当前所安装的Apache的执行性能,主要是显示你安装的Apache每秒可以处理多少个请求. #ab -v可以看出其基本信息 ...

  9. 压力测试工具集合(ab,webbench,Siege,http_load,Web Application Stress)

    压力测试工具集合(ab,webbench,Siege,http_load,Web Application Stress) 1 Apache附带的工具ab ab的全称是ApacheBench,是Apac ...

随机推荐

  1. MFC笔记2

    1.Create()函数创建,该函数原型如下: BOOL Create( LPCTSTR lpszCaption, DWORD dwStyle, const RECT& rect, CWnd* ...

  2. 使用::befor和::after伪元素在网站中添加图标

    css3为了区分伪类和伪元素,伪元素采用双冒号写法. 常见伪类——:hover,:link,:active,:target,:not(),:focus. 常见伪元素——::first-letter,: ...

  3. 大数据入门到精通8-spark RDD 复合key 和复合value 的map reduce操作

    一.做基础数据准备 这次使用fights得数据. scala> val flights= sc.textFile("/user/hdfs/data/Flights/flights.cs ...

  4. elk中es集群web管理工具cerebro

    cerebo是kopf在es5上的替代者 安装es虽然不能再root下运行,但是cerebro 可以 run as root is ok wget https://github.com/lmeneze ...

  5. CF 317 A. Lengthening Sticks(容斥+组合数学)

    传送门:点我 A. Lengthening Sticks  time limit per test        1 second You are given three sticks with po ...

  6. 为了应对异常情况,提供最原始的python第三方库的安装方法:手动安装。往往是Windows用户需要用到这种方法。

    进入pypi.python.org,搜索你要安装的库的名字,这时候有3中可能: 第一种是exe文件,这种最方便,下载满足你的电脑系统和python环境的对应的exe,再一路点击next就可以安装. 第 ...

  7. git 添加分支并与远程连接

    今天由于项目需要,要改版,为了不影响当前网站,所以用分支来管理 首先,在本地添加分支dev git checkout -b dev 提交远程,让同事拉取这个分支,我是直接push了,推到远程. 同事在 ...

  8. Solr定时导入功能实现

    需要实现Solr定时导入功能的话,我们可以通过使用Solr自身所集成的dataimportscheduler调度器实现 下载对应的jar包,下载地址https://code.google.com/ar ...

  9. 代码之髓读后感——类&继承

    面向对象 语言中的用语并不是共通的,在不同语言中,同一个用语的含义可能会有很大差别. C++的设计者本贾尼·斯特劳斯特卢普对类和继承给予了正面肯定,然而,"面向对象"这个词的发明者 ...

  10. 使用Shell脚本对Linux系统和进程资源进行监控

    ShellLinux脚本 摘要:Shell语言对于接触Linux的人来说都比较熟悉,它是系统的用户界面,提供了用户与内核进行交互操作的一种接口.本文我们以Bash做为实例总结了使用Shell对系统和进 ...