Apache Bench (ab)

yum install -y httpd-tools

ab -c 10 -n 100 http://www.example.com/index.php

-c10 表示并发用户数为10
-n100 表示请求总数为100

This is ApacheBench, Version 2.3 <$Revision: 1430300 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 192.168.199.85 (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:
Server Hostname: 192.168.199.85
Server Port: 3814

Document Path: /portals/index
Document Length: 11999 bytes HTTP响应数据的正文长度

Concurrency Level: 200
Time taken for tests: 2.132 seconds 所有这些请求处理完成所花费的时间 
Complete requests: 1000 完成请求数 
Failed requests: 0 失败请求数 
Write errors: 0
Total transferred: 12136000 bytes 网络总传输量 
HTML transferred: 11999000 bytes HTML内容传输量
Requests per second: 469.10 #/sec 吞吐量-每秒请求数
Time per request: 426.350 ms 服务器收到请求,响应页面要花费的时间
Time per request: 2.132 [ms] (mean, across all concurrent requests) 并发的每个请求平均消耗时间
Transfer rate: 5559.55 [Kbytes/sec] received 平均每秒网络上的流量,可以帮助排除是否存在网络流量过大导致响应时间延长的问题

Connection Times (ms)
min mean[+/-sd] median max
Connect: 1 26 136.7 1 1006
Processing: 6 364 295.5 297 1741
Waiting: 3 353 297.1 286 1740
Total: 7 391 330.3 308 1980


Percentage of the requests served within a certain time (ms)
50% 308 50% 的用户响应时间小于 308 毫秒 
66% 450 80 % 的用户响应时间小于 450 毫秒
75% 552
80% 618
90% 832
95% 1028
98% 1354
99% 1650
100% 1980 (longest request) 最大的响应时间小于 2000 毫秒 

links:
http://httpd.apache.org/docs/2.4/programs/ab.html

此条目发表在article分类目录。将固定链接加入收藏夹。