如何对网站服务器进行压力测试

1.yum install -y httpd-tools

  ab命令被集成到了httpd服务器中,所以想要使用ab命令需要先安装httpd服务

  ab -c 并发请求HTTP报文数量 -n 总共发送少个请求报文  http://www.oldboy.com/index,html

ab命令的使用方法和常用选项

ab [选项] [http[s]://]hostname[:port]/path

常用选项:
-n requests     Number of requests to perform
         在测试会话中所执行的请求总个数,默认一个
-c concurrency  Number of multiple requests to make at a time
         一次产生的请求个数,默认一个

2. 实例

[root@web01 conf.d]# ab -c 200 -n 200 http://www.oldboy.com/index.html
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 www.oldboy.com (be patient)
Completed 100 requests
Completed 200 requests
Finished 200 requests


Server Software:        nginx/1.14.1            ---被测试的httpd服务器版本
Server Hostname:        www.oldboy.com          ---服务器主机名
Server Port:            80                      ---服务器端口
        
Document Path:          /index.html             ---测试的文档页面
Document Length:        195 bytes               ---测试的文档大小     
        
Concurrency Level:      200                     ---并发数
Time taken for tests:   2.746 seconds           ---整个测试时间
Complete requests:      200                     ---完成请求个数
Failed requests:        118                     ---失败请求格式  
   (Connect: 0, Receive: 0, Length: 118,        Exceptions: 0)
Write errors:           0        
Non-2xx responses:      200        
Total transferred:      104236 bytes            ---整个测试过程中总传输字节数
HTML transferred:       39118 bytes             ---整个测试过程中HTML传输字节数  
Requests per second:    72.82 [#/sec] (mean)     ---每秒处理请求数,mean 表示这是一个平均值
Time per request:       2746.492 [ms] (mean)     ---平均请求时间,mean表示这是一个平均值
Time per request:       13.732 [ms] (mean, across all concurrent requests) ---每个请求实际运行时间的平均值,mean表示这是一个平均值
Transfer rate:          37.06 [Kbytes/sec] received ---传输速率

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:      254  266   7.0    266     277
Processing:   256  453 217.6    400    1816
Waiting:      256  453 217.6    400    1816
Total:        511  718 217.0    668    2074

Percentage of the requests served within a certain time (ms)
  50%    668
  66%    689
  75%    712
  80%    968
  90%    992
  95%   1112
  98%   1250
  99%   1358
 100%   2074 (longest request)

3. 注意

  测试上限一般是由打开文件的数量决定的,这个数值可以通过ulimit -a或ulimit -n命令查看,默认大小为1024。解决办法就是ulimit -n [数值],来提高打开文件的数量上限,测试和被测试的都要提升。

猜你喜欢

转载自www.cnblogs.com/zhanghongqi/p/11825297.html
今日推荐