有人能告诉我如何使用apache bench工具(ab)加载测试我的网站的过程吗?

我想了解以下几点:

网站每分钟能处理多少人?

请引导我通过我应该运行的命令来解决这个问题。

我尝试了每一个教程,它们都令人困惑。


当前回答

仅使用ab对API进行负载测试是不够的。然而,我认为它是一个很好的工具,可以让你对网站的性能有一个基本的了解。

如果你想使用ab命令在后台同时测试多个API端点,使用不同的数据,你需要使用“nohup”命令。即使关闭终端,它也会运行任何命令。

我写了一个简单的脚本,自动化整个过程,请随意使用:http://blog.ikvasnica.com/entry/load-test-multiple-api-endpoints-concurrently-use-this-simple-shell-script

其他回答

执行步骤: 负载测试命令

步骤1 -安装Xampp。 步骤2 -打开CMD。 步骤3 -从CMD转到Apache工作台目的地(cd C:\xampp\ Apache \bin)。 步骤4—粘贴命令 ab -n 100 -c 10 -k -H "Accept-Encoding: gzip, deflate" http://localhost:port/ 第五步——等待时机。你完成


只有主命令“Get”

ab -k -c 25 -n 2000 http://192.168.1.113:3001/api/v1/filters/3

在windows上设置Apache Bench(AB)的步骤(IMO -推荐)。 步骤1 -安装Xampp。 步骤2 -打开CMD。 步骤3 -从CMD进入apache bench目的地(cd C:\xampp\apache\bin) 步骤4 -粘贴命令(ab -n 100 -c 10 -k - h "Accept-Encoding: gzip, deflate" http://localhost:yourport/) 第五步——等待时机。你做的

请求后负载测试的最佳解决方案之一。点击这里

仅使用ab对API进行负载测试是不够的。然而,我认为它是一个很好的工具,可以让你对网站的性能有一个基本的了解。

如果你想使用ab命令在后台同时测试多个API端点,使用不同的数据,你需要使用“nohup”命令。即使关闭终端,它也会运行任何命令。

我写了一个简单的脚本,自动化整个过程,请随意使用:http://blog.ikvasnica.com/entry/load-test-multiple-api-endpoints-concurrently-use-this-simple-shell-script

我也很好奇,如果我可以测量我的脚本与apache abs或构造/销毁php测量脚本或php扩展的速度。

最后两个对我来说是失败的:它们是近似的。 然后我想试试“腹肌”和“腹肌”。

命令“ab -k -c 350 -n 20000 example.com/”非常漂亮,因为它更简单!

但是有人想过在apache服务器(例如www.apachefriends.org)上使用“localhost”吗?

你应该在根目录下创建一个文件夹,比如“bench”,其中有两个文件:测试“bench.php”和引用“void.php”。

然后:基准测试!

bench.php

<?php

for($i=1;$i<50000;$i++){
    print ('qwertyuiopasdfghjklzxcvbnm1234567890');
}
?>

void.php

<?php
?>

在你的桌面上,你应该使用。bat文件(在Windows中):

bench.bat

"c:\xampp\apache\bin\abs.exe" -n 10000 http://localhost/bench/void.php
"c:\xampp\apache\bin\abs.exe" -n 10000 http://localhost/bench/bench.php
pause

现在如果你仔细注意……

无效脚本不会产生零结果!! 所以结论是:从第二个结果来看,第一个结果应该减少!!

这里我得到:

c:\xampp\htdocs\bench>"c:\xampp\apache\bin\abs.exe" -n 10000 http://localhost/bench/void.php
This is ApacheBench, Version 2.3 <$Revision: 1826891 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking localhost (be patient)
Completed 1000 requests
Completed 2000 requests
Completed 3000 requests
Completed 4000 requests
Completed 5000 requests
Completed 6000 requests
Completed 7000 requests
Completed 8000 requests
Completed 9000 requests
Completed 10000 requests
Finished 10000 requests


Server Software:        Apache/2.4.33
Server Hostname:        localhost
Server Port:            80

Document Path:          /bench/void.php
Document Length:        0 bytes

Concurrency Level:      1
Time taken for tests:   11.219 seconds
Complete requests:      10000
Failed requests:        0
Total transferred:      2150000 bytes
HTML transferred:       0 bytes
Requests per second:    891.34 [#/sec] (mean)
Time per request:       1.122 [ms] (mean)
Time per request:       1.122 [ms] (mean, across all concurrent requests)
Transfer rate:          187.15 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.3      0       1
Processing:     0    1   0.9      1      17
Waiting:        0    1   0.9      1      17
Total:          0    1   0.9      1      17

Percentage of the requests served within a certain time (ms)
  50%      1
  66%      1
  75%      1
  80%      1
  90%      1
  95%      2
  98%      2
  99%      3
 100%     17 (longest request)

c:\xampp\htdocs\bench>"c:\xampp\apache\bin\abs.exe" -n 10000 http://localhost/bench/bench.php
This is ApacheBench, Version 2.3 <$Revision: 1826891 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking localhost (be patient)
Completed 1000 requests
Completed 2000 requests
Completed 3000 requests
Completed 4000 requests
Completed 5000 requests
Completed 6000 requests
Completed 7000 requests
Completed 8000 requests
Completed 9000 requests
Completed 10000 requests
Finished 10000 requests


Server Software:        Apache/2.4.33
Server Hostname:        localhost
Server Port:            80

Document Path:          /bench/bench.php
Document Length:        1799964 bytes

Concurrency Level:      1
Time taken for tests:   177.006 seconds
Complete requests:      10000
Failed requests:        0
Total transferred:      18001600000 bytes
HTML transferred:       17999640000 bytes
Requests per second:    56.50 [#/sec] (mean)
Time per request:       17.701 [ms] (mean)
Time per request:       17.701 [ms] (mean, across all concurrent requests)
Transfer rate:          99317.00 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.3      0       1
Processing:    12   17   3.2     17      90
Waiting:        0    1   1.1      1      26
Total:         13   18   3.2     18      90

Percentage of the requests served within a certain time (ms)
  50%     18
  66%     19
  75%     19
  80%     20
  90%     21
  95%     22
  98%     23
  99%     26
 100%     90 (longest request)

c:\xampp\htdocs\bench>pause
Press any key to continue . . .

90-17= 73,这是我期待的结果!