【问题标题】:Apache Requests per second [closed]每秒 Apache 请求数 [关闭]
【发布时间】:2014-01-14 15:57:22
【问题描述】:

我已经安装了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 个请求。为什么分数相差这么大?这是一个相同的文件。

【问题讨论】:

  • 同一个文件处理方式不同。使用 DHL 和普通邮件发送信封。相同的邮件 - 但会在不同的时间送达

标签: php apache optimization nginx centos


【解决方案1】:

这是因为index.html 是一个纯 HTML 文件,基本上只是在被请求后立即从服务器中丢弃。

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

【讨论】:

  • 谢谢回答,你能说它通常是否适合我的配置:CPU 1x2Ghz RAM 2Gb Bandwidth 100Mb/s
  • 任何系统上的任何配置都是正常的。一个简单的事实是一个文件是直接未解析的 HTMl 而另一个是 PHP 将被解析。对于世界上任何地方的任何服务器来说,这都是现实。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2012-06-23
  • 2012-03-14
  • 2010-09-25
  • 1970-01-01
  • 1970-01-01
  • 2016-03-18
  • 1970-01-01
相关资源
最近更新 更多