使用Apache自带ab工具测试WebService接口
来源:互联网 发布:杭州网站设计宣盟网络 编辑:程序博客网 时间:2024/04/26 03:55
进入<APACHE_HOME>/bin/目录下,运行ab可以看到如下结果:
D:\Apache2.2\bin>ab -h
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
-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)
由上可以看出ab的各种用法,所以我决定采用Post的方法模拟WebService请求,具体如下:
ab -c 1000 -n 1000 -p login.txt -T Content-Type:text/xml;charset=utf-8 http://192.168.1.17:8080/JYWebservice/EntryPort?op=call
注意:用户数(-c)不能小于请求次数(-n)
经过测试发现,以上参数为必填;(WebService部分此处不做过多说明)
模拟请求的Body内容即login.txt,具体内容如下:
<?xml version="1.0" encoding="utf-8" standalone="no"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<ns2:call xmlns:ns2="http://entry.ws.css.com/">
<arg0>[{"password":"123456","userAccount":"1630001","sourceType":1,"sessionId":""}]</arg0>
<arg1>LOGIN</arg1>
</ns2:call>
</soap:Body>
</soap:Envelope>
如此,运行即可得到测试结果:
D:\Apache2.2\bin>ab -c 100 -n 100 -p login.txt -T Content-Type:text/xml;charset=
utf-8 http://192.168.1.17:8080/JYWebservice/EntryPort?op=call
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 192.168.1.17 (be patient).....done
Server Software: Apache-Coyote/1.1
Server Hostname: 192.168.1.17
Server Port: 8080
Document Path: /JYWebservice/EntryPort?op=call
Document Length: 1012 bytes
Concurrency Level: 100
Time taken for tests: 0.425 seconds
Complete requests: 100
Failed requests: 0
Write errors: 0
Total transferred: 126500 bytes
Total POSTed: 55700
HTML transferred: 101200 bytes
Requests per second: 235.29 [#/sec] (mean)--------------------------------------- >吞吐率
Time per request: 425.000 [ms] (mean)--------------------------------------------->请求用户等待时间
Time per request: 4.250 [ms] (mean, across all concurrent requests)----->请求服务器处理时间(即吞吐率的倒数)
Transfer rate: 290.67 [Kbytes/sec] received
127.99 kb/s sent
418.66 kb/s total
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.3 0 1
Processing: 318 386 22.6 393 423
Waiting: 317 385 22.7 392 422
Total: 318 386 22.6 393 424
Percentage of the requests served within a certain time (ms)
50% 393
66% 398
75% 402
80% 404
90% 409
95% 414
98% 420
99% 424
100% 424 (longest request)
D:\Apache2.2\bin>ab -h
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
-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)
由上可以看出ab的各种用法,所以我决定采用Post的方法模拟WebService请求,具体如下:
ab -c 1000 -n 1000 -p login.txt -T Content-Type:text/xml;charset=utf-8 http://192.168.1.17:8080/JYWebservice/EntryPort?op=call
注意:用户数(-c)不能小于请求次数(-n)
经过测试发现,以上参数为必填;(WebService部分此处不做过多说明)
模拟请求的Body内容即login.txt,具体内容如下:
<?xml version="1.0" encoding="utf-8" standalone="no"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<ns2:call xmlns:ns2="http://entry.ws.css.com/">
<arg0>[{"password":"123456","userAccount":"1630001","sourceType":1,"sessionId":""}]</arg0>
<arg1>LOGIN</arg1>
</ns2:call>
</soap:Body>
</soap:Envelope>
如此,运行即可得到测试结果:
D:\Apache2.2\bin>ab -c 100 -n 100 -p login.txt -T Content-Type:text/xml;charset=
utf-8 http://192.168.1.17:8080/JYWebservice/EntryPort?op=call
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 192.168.1.17 (be patient).....done
Server Software: Apache-Coyote/1.1
Server Hostname: 192.168.1.17
Server Port: 8080
Document Path: /JYWebservice/EntryPort?op=call
Document Length: 1012 bytes
Concurrency Level: 100
Time taken for tests: 0.425 seconds
Complete requests: 100
Failed requests: 0
Write errors: 0
Total transferred: 126500 bytes
Total POSTed: 55700
HTML transferred: 101200 bytes
Requests per second: 235.29 [#/sec] (mean)--------------------------------------- >吞吐率
Time per request: 425.000 [ms] (mean)--------------------------------------------->请求用户等待时间
Time per request: 4.250 [ms] (mean, across all concurrent requests)----->请求服务器处理时间(即吞吐率的倒数)
Transfer rate: 290.67 [Kbytes/sec] received
127.99 kb/s sent
418.66 kb/s total
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.3 0 1
Processing: 318 386 22.6 393 423
Waiting: 317 385 22.7 392 422
Total: 318 386 22.6 393 424
Percentage of the requests served within a certain time (ms)
50% 393
66% 398
75% 402
80% 404
90% 409
95% 414
98% 420
99% 424
100% 424 (longest request)
- 使用Apache自带ab工具测试WebService接口
- Apache自带的性能测试工具ab的使用
- apache 自带压力测试工具ab.exe的使用
- Apache自带的ab测试工具的使用
- Apache自带压力测试工具ab
- apache自带的测试工具AB
- AB --- APACHE自带的压力测试工具 (APACHE BENCHMARK )
- ab --- apache自带的压力测试工具 (apache benchmark )使用
- 网站压力测试方法- Apache自带的性能测试工具ab的使用
- 使用apache自带的ab压力测试工具测试网站性能
- Apache自带网站压力测试工具ab
- Apache自带ab性能测试工具学习
- apache自带ab工具对网站进行压力测试
- Apache自带压力测试工具ab用法简介
- Apache自带ab性能测试工具学习
- apache自带的ab压力测试工具用法详解
- 【转载】Apache自带压力测试工具AB的使用方法
- apache自带的ab压力测试工具用法详解
- C#操作XML小结
- 学习笔记-JAVA基础
- 解决T2A W2A A2W的报错error C2065: “_lpw”: 未声明的标识符
- Try to finish hcheck after restore database
- maven 配置篇 之pom.xml
- 使用Apache自带ab工具测试WebService接口
- Css选择器命名规则
- H264基本概念之 宏块、片和片组 .
- vc常用数据类型使用转换详解-(2013/09/18)
- textbox有个AutoCompleteType的属性
- Android NFC相关资料之MifareClassic卡(读写)
- c# Invoke和BeginInvoke 区别
- How to clear the archive log
- 随机产生一些数传递给一个函数,写程序找出并维护这些数的中位数。