利用ab.exe做压力测试,然后去优化服务器的环境。
利用这个工具非常简单,首先下载ab.exe,然后打开命令cmd执行并发模拟即可。
ab.exe是一个性能检测工具,是apache server中的一个小组件,使用简单,方便。 下载地址:http://files.cnblogs.com/files/gossip/ab.zip
这是使用说明:
ab.exe [options] [http://]hostname[:port]/path Options are: -n requests 模拟请求次数 -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)
下面是那baidu测试一下,第二次测试的时候被关闭了我的请求
ab.exe -n 10 -c 10 http://www.baidu.com/ 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.baidu.com (be patient).....done Server Software: BWS/1.1 Server Hostname: www.baidu.com Server Port: 80 Document Path: / Document Length: 279946 bytes Concurrency Level: 10 Time taken for tests: 2.480 seconds Complete requests: 10 Failed requests: 9 (Connect: 0, Receive: 0, Length: 9, Exceptions: 0) Write errors: 0 Total transferred: 2810737 bytes HTML transferred: 2799180 bytes Requests per second: 4.03 [#/sec] (mean) Time per request: 2480.118 [ms] (mean) Time per request: 248.012 [ms] (mean, across all concurrent requests) Transfer rate: 1106.75 [Kbytes/sec] received Connection Times (ms) min mean[+/-sd] median max Connect: 86 111 15.0 117 133 Processing: 1359 1612 196.2 1621 2055 Waiting: 208 569 270.4 570 1005 Total: 1476 1724 193.4 1718 2153 Percentage of the requests served within a certain time (ms) 50% 1718 66% 1789 75% 1823 80% 1857 90% 2153 95% 2153 98% 2153 99% 2153 100% 2153 (longest request) ab.exe -n 100 -c 100 http://www.baidu.com/ 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.baidu.com (be patient)...apr_socket_recv: 远程主机强迫关闭了一个现有的连接。 (730054) Total of 3 requests completed