Apache Bench是著名Web服务器软件apache附带的一个小工具,它可以同时模拟多个并发请求,测试apache等Web服务器的最大承载压力,同时也可以根据Apache Bench提供的测试结果对服务器性能参数进行调整。
由于本参数相当于单IP CC攻击,请不要随意测试别人的网站。
一、安装Apache
yum install httpd
最简单获取apache的方法,在CentOS系统下执行以上命令(请注意保证不要和Nginx等其它Web服务器冲突)。
二、使用ab命令
Apache Bench(ab)最基本的用法是:
ab -n 100 -c 100 http://www.kwx.gd/
在SSH中执行以上命令,黄色部分则修改成您的网站地址,必须在后方加上“/”,或指定相应文件。
“-n”表示:每次请求数,默认不能超过1024个,否则需要修改系统进程限制。
“-c”表示:1个请求的并发连接数,默认最大不能超过50000。
并发连接数不能够大于请求数,即C≤ N 否则会提示:Cannot use concurrency level greater than total number of requests。
三、查看结果

This is ApacheBench, VersiON 2.0.40-dev <$Revision: 1.146 $> apache-2.0 Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ Copyright 2006 The Apache Software Foundation, http://www.apache.org/ Benchmarking www.kwx.gd (be patient) Finished 130 requests Server Software: nginx/1.0.10 Server Hostname: www.kwx.gd Server Port: 80 Document Path: / Document Length: 20718 bytes Concurrency Level: 1020 Time taken for tests: 20.6751 seconds Complete requests: 130 Failed requests: 0 Write errors: 0 Total transferred: 3041510 bytes HTML transferred: 2957081 bytes Requests per second: 6.50 [#/sec] (mean) Time per request: 156976.039 [ms] (mean) Time per request: 153.898 [ms] (mean, across all concurrent requests)
Transfer rate: 148.45 [Kbytes/sec] received Connection Times (ms) min mean[+/-sd] median max Connect: 322 346 18.0 338 401 Processing: 1344 8898 4081.5 9795 19341 Waiting: 669 7629 3782.7 8802 18617 Total: 1682 9245 4087.6 10148 19684 Percentage of the requests served within a certain time (ms) 50% 10148 66% 11054 75% 11567 80% 12797 90% 14636 95% 15551 98% 16834 99% 18119 100% 19684 (longest request)
四、其它参数
选项 | 相应功能 |
-n | 执行请求的数量 |
-c | 每个请求的并发连接数 |
-t | 等待响应时间 |
-V | 显示版本信息
|
评论专区