每秒Apache请求数

时间:2013-12-27 03:17:32

标签: php apache optimization nginx centos

我已安装centos6 + apache(后端)+ nginx(前端)+ APC。如果使用以下命令对其进行基准测试:

ab -n 1000 -c 100 http://domain.com/index.html

Server Software:        nginx/1.0.15
Server Hostname:        domain.com
Server Port:            80

Document Path:          /index.html
Document Length:        1423 bytes

Concurrency Level:      100
Time taken for tests:   0.109 seconds
Complete requests:      1000
Failed requests:        0
Write errors:           0
Total transferred:      1730000 bytes
HTML transferred:       1423000 bytes
Requests per second:    9173.81 [#/sec] (mean)
Time per request:       10.901 [ms] (mean)
Time per request:       0.109 [ms] (mean, across all concurrent requests)
Transfer rate:          15498.72 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    2   1.5      1       6
Processing:     3    8   2.4      8      16
Waiting:        1    7   2.9      7      16
Total:          6   10   1.8     10      17

Percentage of the requests served within a certain time (ms)
  50%     10
  66%     11
  75%     11
  80%     11
  90%     13
  95%     13
  98%     14
  99%     15
 100%     17 (longest request)

我每秒收到9173.81个请求,但是如果使用命令:

ab -n 1000 -c 100 http://domain.com/index.**php**

哪个文件内容相同,但*.php扩展名。

Server Software:        nginx/1.0.15
Server Hostname:        domain.com
Server Port:            80

Document Path:          /test.php
Document Length:        902 bytes

Concurrency Level:      100
Time taken for tests:   1.277 seconds
Complete requests:      1000
Failed requests:        0
Write errors:           0
Total transferred:      1109000 bytes
HTML transferred:       902000 bytes
Requests per second:    783.38 [#/sec] (mean)
Time per request:       127.652 [ms] (mean)
Time per request:       1.277 [ms] (mean, across all concurrent requests)
Transfer rate:          848.41 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    2   4.8      0      18
Processing:     4  122  34.7    138     162
Waiting:        2  122  34.8    138     162
Total:         21  123  33.4    139     168

Percentage of the requests served within a certain time (ms)
  50%    139
  66%    150
  75%    151
  80%    152
  90%    159
  95%    161
  98%    162
  99%    162
 100%    168 (longest request)

我每秒收到783.38个请求。为什么得分如此之大?这是一个完全相同的文件。

1 个答案:

答案 0 :(得分:1)

这是因为index.html是一个直接的HTML文件&基本上只是在被请求后立即从服务器上扔掉。

相比之下,index.php是一个Apache必须解析的PHP文件。根据内容,这可能是一项简单或复杂的任务,但与直接的HTML文件请求相比,处理起来总是更“昂贵”。