使用 Apache Benchmark 实用程序
ab 程序与 Apache Web 服务器一起提供以对 Web 服务器进行基准测试。因此,Watson™ Explorer Engine 通常会作为 CGI 可执行文件在 Web 服务器中运行,这有利于了解 Web 服务器的操作性能。ab 应用程序旨在提供当前 Apache 安装的性能信息,突出显示 Apache 安装每秒能够提供的请求数。
该信息可用于确定独立处理 Watson Explorer Engine 以及运行 Watson Explorer Engine 时的 Web 服务器的最大负载。ab 应用程序可以在运行 Watson Explorer Engine 时测试 Web 服务器,这样您可以从最终用户透视图获得整个应用程序的性能的精确基准测试。
ab 应用程序作为 Apache 安装包的一部分来安装。在许多 Linux 发行版中,该应用程序包含于 httpd-tools 包中。有关如何获取 ab 实用程序的信息,请参阅操作系统的 Apache 文档。
以下是 ab 提供的帮助信息:
# ab -h
Usage: ab [options] [http[s]://]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)
m-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)
-Z ciphersuite Specify SSL/TLS cipher suite (See openssl ciphers)
-f protocol Specify SSL/TLS protocol (SSL2, SSL3, TLS1, or ALL)
以下是负载测试 Watson Explorer Engine 安装的示例:
# ab -n 1000 -c 10 http://localhost/velocity/cgi-bin/query-meta
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 localhost (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Completed 600 requests
Completed 700 requests
Completed 800 requests
Completed 900 requests
Completed 1000 requests
Finished 1000 requests
Server Software: Apache/2.2.15
Server Hostname: localhost
Server Port: 80
Document Path: /velocity/cgi-bin/query-meta
Document Length: 140256 bytes
Concurrency Level: 10
Time taken for tests: 55.911 seconds
Complete requests: 1000
Failed requests: 65
(Connect: 0, Receive: 0, Length: 65, Exceptions: 0)
Write errors: 0
Total transferred: 140402934 bytes
HTML transferred: 140255934 bytes
Requests per second: 17.89 [#/sec] (mean)
Time per request: 559.107 [ms] (mean)
Time per request: 55.911 [ms] (mean, across all concurrent requests)
Transfer rate: 2452.35 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.0 0 1
Processing: 366 558 104.9 541 1350
Waiting: 353 528 104.5 511 1320
Total: 366 558 104.9 541 1350
Percentage of the requests served within a certain time (ms)
50% 541
66% 570
75% 593
80% 605
90% 650
95% 701
98% 941
99% 1059
100% 1350 (longest request)
以上测试表明运行 Watson Explorer Engine 的此实例的服务器每秒能够处理 17.89 个请求。这是运行 query-meta 和搜索 example-metadata 集合时的缺省配置。
以下是使用 meta-searching 和搜索集合进行搜索时负载测试的输出:
# ab -n 100 -c 10 "http://localhost/velocity/cgi-bin/query-meta?v:project=query-meta&query=news"
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 localhost (be patient).....done
Server Software: Apache/2.2.15
Server Hostname: localhost
Server Port: 80
Document Path: /velocity/cgi-bin/query-meta?v:project=query-meta&query=news
Document Length: 124894 bytes
Concurrency Level: 10
Time taken for tests: 70.536 seconds
Complete requests: 100
Failed requests: 99
(Connect: 0, Receive: 0, Length: 99, Exceptions: 0)
Write errors: 0
Total transferred: 12478129 bytes
HTML transferred: 12463429 bytes
Requests per second: 1.42 [#/sec] (mean)
Time per request: 7053.553 [ms] (mean)
Time per request: 705.355 [ms] (mean, across all concurrent requests)
Transfer rate: 172.76 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.1 0 0
Processing: 2666 6838 1842.3 6547 13812
Waiting: 2650 6822 1842.5 6533 13798
Total: 2666 6838 1842.3 6547 13812
Percentage of the requests served within a certain time (ms)
50% 6547
66% 7243
75% 7676
80% 8149
90% 8995
95% 10025
98% 13689
99% 13812
100% 13812 (longest request)
在 meta-searching 包含于查询中时,您会发现性能有很大的差异。第一次运行是针对总共有 1000 个请求的搜索集合(10 个并发),平均完成时间是 0.5 秒。第二次运行是针对收集和联合来源,只有 100 个请求(10 个并发),平均完成时间为 6.5 秒。在启用联合之后,完成第 10 个请求(请求总数)的次数增加了 13 倍。