首页 > 编程知识 正文

测试吞吐量,吞吐量测试属于什么测试

时间:2023-05-06 08:08:09 阅读:225826 作者:4138

吞吐率指的是单位时间内服务器处理的请求数,通常使用 reqs/s (服务器每秒处理的请求数量)来表示。 吞吐率只描述了服务器在实际运行期间单位时间内处理的请求数,而我们更加关心的是服务器并发处理能力的上限,即单位时间内服务器能够处理的最大请求数(即最大吞吐率)。但在测试时,很难调动足够多的人测试服务器的最大吞吐率。所以,需要使用某些方法模拟足够数目的并发用户数,这种方法称为“压力测试”。 压力测试的工具很多,如LoadRunner、JMeter和ab等。由于LoadRunner和JMeter使用起来过于复杂,故这里我们介绍一种比较简单的压力测试工具ab。 ab(Apache Bench)是Apache附带的一个压力测试软件。它操作起来比较简单,功能基本能够满足我们的要求。 打开cmd,切换至Apache的轻松的画笔目录(如:我的是  E:xamppapache轻松的画笔 ) cd  E:xamppapache轻松的画笔 ab -h          // 打印出ab工具的使用信息 Usage: ab [options] [http://]hostname[:port]/pathOptions are: -n requests Number of requests to perform -c concurrency Number of multiple requests to make at a time -t timelimit Seconds to max. to spend on benchmarking This implies -n 50000 -s timeout Seconds to max. wait for each response Default is 30 seconds -b windowsize Size of TCP send/receive buffer, in bytes -B address Address to 轻松的画笔d to when making outgoing connections -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 to use for POST/PUT data, 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. -q Do not show progress when doing more than 150 requests -l Accept variable document length (use this for dynamic pages) -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. -m method Method name -h Display usage information (this message)
ab的选项比较多,常用的有以下几个: n   在测试会话中执行的请求的数目,默认执行一个请求。 c   要创建的并发用户数,默认创建一个用户数。 t   等待Web服务器响应的最大时间(单位:秒),默认没有时间限制 k   使用Keep Alive(长连接)特性 c   对请求附加一个Cookie,形式为name=value
下面使用 ab 进行一次压力测试: ab -n1000 -c10 demo.com/index.php 输出内容如下: This is ApacheBench, Version 2.3 <$Revision: 1604373 $>Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/Licensed to The Apache Software Foundation, http://www.apache.org/Benchmarking demo.com (be patient)Completed 100 requestsCompleted 200 requestsCompleted 300 requestsCompleted 400 requestsCompleted 500 requestsCompleted 600 requestsCompleted 700 requestsCompleted 800 requestsCompleted 900 requestsCompleted 1000 requestsFinished 1000 requestsServer Software: Apache/2.4.10Server Hostname: demo.comServer Port: 80Document Path: /index.phpDocument Length: 36 bytesConcurrency Level: 10Time taken for tests: 0.452 secondsComplete requests: 1000Failed requests: 0Total transferred: 254000 bytesHTML transferred: 36000 bytesRequests per second: 2210.43 [#/sec] (mean)Time per request: 4.524 [ms] (mean)Time per request: 0.452 [ms] (mean, across all concurrent requests)Transfer rate: 548.29 [Kbytes/sec] receivedConnection Times (ms) min mean[+/-sd] median maxConnect: 0 0 1.8 0 16Processing: 0 4 7.0 0 31Waiting: 0 4 6.8 0 31Total: 0 4 7.1 0 31Percentage of the requests served within a certain time (ms) 50% 0 66% 0 75% 16 80% 16 90% 16 95% 16 98% 16 99% 16 100% 31 (longest request)
从测试结果可以看出,吞吐率为 2210.43reqs/s。
测试结果中,我们通常会关注以下几个内容: Server Software:被测试的Web服务器软件的名称和版本。
Server Hostname:请求URL中的主机名称。 Server Port:被测试的Web服务器的监听端口。 Document Path:请求的URL的绝对路径。 Document Length:HTTP响应数据的正文的长度。 Concurrency Level:并发的用户数,设置的 c 参数。 Time taken for tests:所有请求处理完毕所花费的总时间。 Complete requests:总请求数,设置的 n 参数。 Failed requests:失败的请求数。 Total transferred:所有请求的响应数据长度总和。 HTML transferred:所有请求的响应数据中正文数据的长度总和。 Requests per second:Web服务器的吞吐率,等于Complete requests/Time taken for tests。 Time per request:用户平均每个请求的等待时间。 Transfer rate:这些请求在单位时间内从服务器取得的数据长度,等于Total transferred/Time taken for tests。

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。