ab压力测试的用法

在阿帕奇服务器的套件中,有一个叫 做ab(ApacheBench)的工具。ApacheBench主要是用来测试阿帕奇服务器执行效率用的

ApacheBench 可以针对某个特定的 URL 仿真出连续的联机请求,同时还可以仿真出同时间点数个相同的联机请求,因此利用 ApacheBench 可帮助我们在网站开发期间仿真实际上线可能的情况,利用仿真出来的数据做为调整服务器设定或程序的依据。 ApacheBench 的用法如下:

Usage: /usr/local/apache/bin/ab [options] [http://]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    -p postfile File containg data to POST

-T content-type Content-type header for POSTing    -v verbosity How much troubleshooting info to print    -w Print out results in HTML tables

-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    -V Print version number and exit    -k Use HTTP KeepAlive feature

-h Display usage information (this message)

假设我们要对 echo.fcg 做测试,仿真 1000 次的联机请求,而且同一时间有 20 个并行的 (concurrent) 联机请求的情况,只要在命令列模式下执行

$ ab -n 1000 -c 20 http://localhost/fcgi-bin/echo.fcg

之后ab工作后会把结果显示出来

This is ApacheBench, Version 1.3

Copyright c 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/

Copyright c 1998-1999 The Apache Group, http://www.apache.org/

Benchmarking localhost (be patient)... Server Software: Apache/1.3.6

Server Hostname: localhost

Server Port: 80

Document Path: /fcgi-bin/echo.fcg

Document Length: 995 bytes

Concurrency Level: 20

Time taken for tests: 6.859 seconds

Complete requests: 1000

Failed requests: 0

Total transferred: 1142000 bytes

HTML transferred: 995000 bytes

Requests per second: 145.79

Transfer rate: 166.50 kb/s received

Connnection Times (ms)

min avg max

Connect: 0 4 61

Processing: 62 128 771

Total: 62 132 832

以上结果指出,在同时间20 个联机请求 (Concurrency Level) 的情况下,完成 1000 次的联机请求,共花了 6.859 秒(Time taken for tests),因此这个程序每秒平均可以处理(Requests per second) 145.79

个联机请求。

时间: 2024-08-28 13:29:11

ab压力测试的用法的相关文章

apache自带的ab压力测试工具用法详解

ab是apache自带的一个很好用的压力测试工具,当安装完apache的时候,就可以在bin下面找到ab 1 我们可以模拟100个并发用户,对一个页面发送1000个请求 ./ab -n1000 -c100 http://www.baidu.com 其中-n代表请求数,-c代表并发数 返回结果: ##首先是apache的版本信息 This is ApacheBench, Version 2.3 <$Revision: 655654 $> Copyright 1996 Adam Twiss, Ze

ASP.NET 页面缓存OutputCache用法实例(附ab压力测试对比图)

本文主要介绍Web窗体页面中的使用方法,MVC中使用方法,大家自行百度. 一.简单一行指令即可实现 <%@ OutputCache VaryByParam="none" Duration="300" %> 这样整个页面就被缓存了,由于我是首页进行的缓存,没有任何参数所以VaryByParam值设置为none,如果希望通过指定的参数来缓存内容可以设置"id;classid"这种形式,或者干脆就用"*",通过所有参数来

apache ab压力测试报错apr_socket_recv

apache ab压力测试报错(apr_socket_recv: Connection reset by peer (104)) apache 自带的ab工具测试,当并发量达到1000多的时候报错如下: [[email protected] ~]# ab -n 100000 -c 1000 http://192.168.2.170/index.htmlThis is ApacheBench, Version 2.3 <$Revision: 655654 $>Copyright 1996 Ada

php-xcache编译安装,及ab压力测试

[[email protected] local]# tar -xf xcache-3.2.0.tar.bz2 [[email protected] xcache-3.2.0]# man -M /usr/local/php/php/man phpize 查看帮助文档 [[email protected] xcache-3.2.0]# /usr/local/php/bin/phpize [[email protected] xcache-3.2.0]# man -M /usr/local/php/

AB压力测试(Windows)

1.Apache服务器安装 链接: http://jingyan.baidu.com/article/29697b912f6539ab20de3cf8.html 2.AB压力测试帮助 http://wangshuaibo.iteye.com/blog/935454 3.帮助文档 ① Apache报ServerRoot must be a valid directory 解决方法:http://jingyan.baidu.com/article/915fc41491c68751384b2040.h

在执行ab压力测试时出现socket: Too many open files (24)的解决方法

当入行压力测试时出现下列错误 [[email protected] ~]# ab -n 3000 -c 3000 http://192.168.0.2/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, htt

apache ab压力测试报错(apr_socket_recv: Connection reset by peer (104))

apache ab压力测试报错(apr_socket_recv: Connection reset by peer (104)) 今天用apache 自带的ab工具测试,当并发量达到1000多的时候报错如下: [[email protected]~]# This is ApacheBench, Version 2.3 <$Revision: 655654 $> Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech

4分钟apache自带ab压力测试工具使用: 2015.10.4

2015.10.44分钟apache自带ab压力测试工具使用:win8.1 wampserver2.5 -Apache-2.4.9-Mysql-5.6.17-php5.5.12-64b 可以参考一下部分讲解有图,我就是打开cmd窗口,进入apache的安装目录(ab一般是apache自带测试工具,所以然后就可以执行需要测试的命令就好了),我的在F:\wamp\bin\apach\apache2.4.9\bin目录下:两种执行方式,1.进入上面说的目录后执行以下命令,如 .\ab -n5000 -

超级web服务器yum 安装apache+源码编译tomcat+awstat+phpmadin+mysql+php+AB压力测试

实验环境: 两台机器:Centos6.4 机器一: 192.168.56.10  安装httpd  php   等整合 机器二: 192.168.56.11 安装 mysql ======================================================================================== (iptables -t nat -I PREROUTING -d 外IP -p tcp -m tcp --dport 端口 -j DNAT --