对于网站性能测试来说,一般我们会使用loadrunner来实现,而它过于庞大,使我们感到有些不爽,而介绍的ApacheBench工具,它小而精,使用简单,效果直观,可以说,是比lr更好用的性能测试工具. 下面介绍几个概念 1:吞吐率(Requests per second) 服务器并发处理能力的量化描述,单位是reqs/s,指的是某个并发用户数下单位时间内处理的请求数。某个并发用户数下单位时间内能处理的大请求数,称之为大吞吐率。 记住:吞吐率是基于并发用户数的。这句话代表了两个含义,1:吞吐率和并发用户数相关;2:不同的并发用户数下,吞吐率一般是不同的。 计算公式:总请求数 / 处理完成这些请求数所花费的时间,即 Request per second = Complete requests / Time taken for tests 2:并发连接数(The number of concurrent connections) 并发连接数指的是某个时刻服务器所接受的请求数目,简单的讲,是一个会话。 3:并发用户数(The number of concurrent users,Concurrency Level) 要注意区分这个概念和并发连接数之间的区别,一个用户可能同时会产生多个会话,也即连接数。在HTTP/1.1下,IE7支持两个并发连接,IE8支持6个并发连接,FireFox3支持4个并发连接,所以相应的,我们的并发用户数得除以这个基数。 下面主要说一下它的几个主要的参数 运行参数 请求为100,并发为10,命令如下:ApacheBench -n100 -c10 http://uri 运行结果
Benchmarking www.cnblogs.com (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 Finished 1000 requests Server Software: Server Hostname: www.cnblogs.com Server Port: 80 Document Path: / Document Length: 45373 bytes Concurrency Level: 10 Time taken for tests: 45.299591 seconds Complete requests: 1000 Failed requests: 0 Write errors: 0 Total transferred: 45679011 bytes HTML transferred: 45373000 bytes Requests per second: 22.08 [#/sec] (mean) Time per request: 452.996 [ms] (mean) Time per request: 45.300 [ms] (mean, across all concurrent requests) Transfer rate: 984.73 [Kbytes/sec] received Connection Times (ms) min mean[+/-sd] median max Connect: 26 44 189.5 31 3035 Processing: 89 405 583.3 284 5190 Waiting: 30 143 344.6 97 5031 Total: 116 450 611.7 315 5224 Percentage of the requests served within a certain time (ms) 50% 315 66% 322 75% 331 80% 343 90% 408 95% 549 98% 3333 99% 3375 5224 (longest request) |