现在的位置: 首页 -> PHP学习 -> php网站压测(ab)

php网站压测(ab)

2017-07-14 23:41评论数 0 ⁄ 被浏览 9000 views+

一般来说核心页面都需要进行压测,特别是秒杀页面,从而知道网站的承受能力,方便暴露一些问题,更好的把控网站。压测工具有很多种,最简单、方便的可以使用ApacheBench,也就是我们熟悉的ab工具,不过只能做一些简单的压测效果。


如果在windows下面压测,安装apache后,bin目录下会有个“ab.exe”;linux下则需要另行安装,拿centos举例可以执行“yum install httpd-tools”进行安装。安装完成后执行“ab”命令就可以看到提示了。


压测命令:ab -kc 10 -n 100 https://www.daixiaorui.com/


参数说明:

k:使用长连接(http keep-alive)。

c:并发数。

n:请求数。


压测结果如下:

[root@reson ~]# ab -kc 10 -n 100 https://www.daixiaorui.com/
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking www.daixiaorui.com (be patient).....done


Server Software:        nginx
Server Hostname:        www.daixiaorui.com
Server Port:            80

Document Path:          /
Document Length:        35687 bytes

Concurrency Level:      10
Time taken for tests:   2.805 seconds
Complete requests:      100
Failed requests:        0
Write errors:           0
Keep-Alive requests:    0
Total transferred:      3604400 bytes
HTML transferred:       3568700 bytes
Requests per second:    35.65 [#/sec] (mean)
Time per request:       280.466 [ms] (mean)
Time per request:       28.047 [ms] (mean, across all concurrent requests)
Transfer rate:          1255.02 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.0      0       0
Processing:    34  274  32.8    279     349
Waiting:       26  274  33.4    278     348
Total:         34  274  32.8    279     349

Percentage of the requests served within a certain time (ms)
  50%    279
  66%    288
  75%    291
  80%    294
  90%    302
  95%    315
  98%    318
  99%    349
 100%    349 (longest request)
[root@reson ~]#


我们主要看这一项:Requests per second:    35.65 [#/sec] (mean)。意思是一秒钟处理的请求数,即代潇瑞博客一秒钟能接受35.65个请求。


不过压测结果还依赖于网络带宽、当前负载等情况的影响。就拿我的网站来说,在远程压测才4.37个请求,因为服务器只有1MB的带宽,即128kb/s左右。

 

文章出自:https://www.daixiaorui.com/read/254.html 本站所有文章,除注明出处外皆为原创,转载请注明本文地址,版权所有。

目前有 0 条评论  @我要评论

    您的每一个评论都是对我的一份支持

     博客二维码

    昵称 *

    邮箱 *