Apache Benchmark 的 PHP 响应时间缓慢

Apache Benchmark 的 PHP 响应时间缓慢

我有一个运行 Apache(prefork mpm)的 VPS,配备 1gb RAM 和 2 x Intel(R) Xeon(R) CPU E5-2620 0 @ 2.00GHz。

我设置了 2 个测试文件来通过 Apache Benchmark 运行:htmltest.html(仅显示一些文本的基本 HTML 文件)phptest.php(一个完全空白的 php 文件)

我对每个测试运行了以下 Apache Benchmark 命令:ab -k -n 1000 -c 70 THE-TEST-URL

结果是:

html测试.html

Concurrency Level:      70
Time taken for tests:   5.374 seconds
Complete requests:      1000
Failed requests:        0
Write errors:           0
Keep-Alive requests:    992
Total transferred:      374658 bytes
HTML transferred:       134000 bytes
Requests per second:    186.10 [#/sec] (mean)
Time per request:       376.145 [ms] (mean)
Time per request:       5.374 [ms] (mean, across all concurrent requests)
Transfer rate:          68.09 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    1   5.5      0      48
Processing:    17   94 454.3     50    5173
Waiting:       17   93 454.3     50    5173
Total:         17   94 458.8     50    5221

php测试.php

Concurrency Level:      70
Time taken for tests:   125.159 seconds
Complete requests:      1000
Failed requests:        0
Write errors:           0
Keep-Alive requests:    997
Total transferred:      196815 bytes
HTML transferred:       0 bytes
Requests per second:    7.99 [#/sec] (mean)
Time per request:       8761.120 [ms] (mean)
Time per request:       125.159 [ms] (mean, across all concurrent requests)
Transfer rate:          1.54 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   4.0      0      58
Processing:  1003 1244  84.7   1235    2953
Waiting:      997 1244  84.9   1235    2953
Total:       1029 1244  85.8   1235    3012

这里肯定出了问题,因为 HTML 文件只花了 5 秒就完成了测试,而空白 PHP 文件却花了整整 2 分钟才完成完全相同的测试。

是否有一个特定的配置文件我应该查看来解决这里的问题?

相关内容