吾爱互联 发表于 2015-4-14 10:19:58

利用Apache Bench测试Web引擎性能

Apache Bench是著名Web服务器软件apache附带的一个小工具,它可以同时模拟多个并发请求,测试apache等Web服务器的最大承载压力,同时也可以根据Apache Bench提供的测试结果对服务器性能参数进行调整。由于本参数相当于单IP CC攻击,请不要随意测试别人的网站。一、安装Apacheyum 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.0Copyright 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 requestsServer Software:      nginx/1.0.10 #Web服务器引擎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 #HTML内容传输字节数Requests per second:    6.50 [#/sec] (mean) #平均返回数据时间Time per request:       156976.039 (mean) #平均响应时间Time per request:       153.898 (mean, across all concurrent requests)#平均并发请求时间Transfer rate:          148.45 received #平均传输速率Connection Times (ms)   #响应时间小、中、大值            minmean[+/-sd] median   maxConnect:      32234618.0    338   401Processing:1344 8898 4081.5   9795   19341Waiting:      669 7629 3782.7   8802   18617Total:       1682 9245 4087.610148   19684Percentage of the requests served within a certain time (ms)50%1014866%1105475%1156780%1279790%1463695%1555198%1683499%18119 100%19684 (longest request)#以上为所有请求的平均速度,如在测试过程中进度到50%时平均响应时间为10148ms,到66%时平均响应时间为11054ms。以上内容由www.kwx.gd整理。四、其它参数选项相应功能-n执行请求的数量-c每个请求的并发连接数-t等待响应时间-V显示版本信息还有部分不常用参数请自行求助搜索引擎。
页: [1]
查看完整版本: 利用Apache Bench测试Web引擎性能