mac自带的apache有限制ab的最大并发数,需要重新安装一个。

下载apache

安装brew

修改hosts

sudo vim /etc/hosts

# add line
199.232.28.133 raw.githubusercontent.com

执行命令

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

安装apr和pcre

利用brew进行安装

brew install apr
brew install pcre

安装apache

./configure --prefix=/usr/local/httpd-2.4.46/ -with-apr=/usr/local/opt/apr -with-apr-util=/usr/local/opt/apr-util/ -with-pcre=/usr/local/opt/pcre/ 
make 
sudo make install

测试

ab -n 1 -c 1 http://www.baidu.com/

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

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


Server Software:        BWS/1.1
Server Hostname:        www.baidu.com
Server Port:            80

Document Path:          /
Document Length:        283659 bytes

Concurrency Level:      1
Time taken for tests:   0.232 seconds
Complete requests:      1
Failed requests:        0
Total transferred:      284815 bytes
HTML transferred:       283659 bytes
Requests per second:    4.31 [#/sec] (mean)
Time per request:       232.169 [ms] (mean)
Time per request:       232.169 [ms] (mean, across all concurrent requests)
Transfer rate:          1198.01 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:       34   34   0.0     34      34
Processing:   198  198   0.0    198     198
Waiting:       53   53   0.0     53      53
Total:        232  232   0.0    232     232

-n表示总请求数,-c表示并发数
返回信息只需要关注 Requests per second(每秒处理请求数)

最后修改:2020 年 10 月 17 日 04 : 42 PM
如果觉得我的文章对你有用,请随意赞赏