呼叫中心 呼叫中心解决方案 呼叫中心开发技术 CTI 呼叫中心系统
09
十一

apache 性能的压力测试

apache是一款很不错的开源服务器软件,几乎所有的linux服务器都用它,也有很多windows服务器摒弃 IIS,而改用它.

该软件随着安装包附送了一个压力测试工具:ab.全称是ApacheBench.可以模拟多个并发请求。

假如要测试的服务器域名为 www.abc.com 测试首页的并发能力,命令可以这么写
#cd /usr/local/apache/bin          (假如安装目录在/usr/local/apache)

./ab -n 1000 -t 3 -c 20 http://www.abc.com/   ( 请注意,被测试网址最后一定要有/)
This is ApacheBench, Version 1.3d <$Revision: 1.73 $> apache-1.3
Copyright (c) 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Copyright (c) 2006 The Apache Software Foundation, http://www.apache.org/

Benchmarking www.abc.com(be patient)
Finished 9 requests
Server Software: Apache/1.3.37
Server Hostname: www.dxinfo.com
Server Port: 80

Document Path: /
Document Length: 23973 bytes

Concurrency Level: 20
Time taken for tests: 3.391 seconds
Complete requests: 9
Failed requests: 0
Broken pipe errors: 0
Total transferred: 260137 bytes
HTML transferred: 255197 bytes
Requests per second: 2.65 [#/sec] (mean)
Time per request: 7535.56 [ms] (mean)
Time per request: 376.78 [ms] (mean, across all concurrent requests)
Transfer rate: 76.71 [Kbytes/sec] received

Connnection Times (ms)
min mean[+/-sd] median max
Connect: 0 15 45.0 0 136
Processing: 278 1746 851.1 2096 2510
Waiting: 140 1715 907.6 2095 2510
Total: 414 1761 822.5 2096 2510

Percentage of the requests served within a certain time (ms)
50% 2096
66% 2096
75% 2371
80% 2510
90% 2510
95% 2510
98% 2510
99% 2510
100% 2510 (last request)

参数解释

-n 1000 表示测试1000次  该测试工具允许的最大测试次数为50000  如果希望测试100次请写成-n 100

-t 3  表示要在3秒内测试完成这100次 如果希望在10秒内完成 请写成 -t 10

-c 20  表示每次发出20个并发  如果想每次发出150个并发 请写成 -c 150 但大多apache默认最大并发为150,如果想超过此数 请修改httpd.conf里面maxconnetions参数

http://www.abc.com/  表示被测试的一个网站,如果想测试某个文件,要写清楚文件名如http://www.abc.com/index.php

输出结果中  最后的几个数据看明白就行了

50% 2096
66% 2096
75% 2371
80% 2510
90% 2510
95% 2510
98% 2510
99% 2510
100% 2510 (last request)

表示50%的请求 小于2096毫秒 66%的请求小于2096毫秒 75%的请求小于2371毫秒…  最长的请求时间为2510毫秒

其他的,请大家查一下字典

另外  也可以执行./ab –help  来查看帮助

帮助文件内容如下

Usage: ./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
-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: zop’
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
-h Display usage information (this message)

没有评论

抱歉,这篇日志的评论已关闭。

抱歉,这篇日志的评论已关闭。