APC& eAccelerator配置

时间:2015-05-08 12:57:33

标签: php performance optimization apc eaccelerator

看起来我做了非常愚蠢的事情:)我正在尝试优化性能,所以我安装了eAccelerator来缓存并加快PHP脚本的执行速度。之后我安装了APC来存储和检索RAM内存中的HTML页面(如果我对此是正确的)。在同时使用eAccelerator和APC 启用对新PHP脚本进行基准测试后,我发现从磁盘读取HTML文件并显示它比从APC缓存显示它更快。这是benchamrk结果和PHP脚本。我需要建议如何配置eAccelerator或APC以获得更好的结果。

ab -kc 500 -n 100000 http://0.0.0.0/html_disk.php
Requests per second:    14197.42 [#/sec] (mean)
Time per request:       35.218 [ms] (mean)
Time per request:       0.070 [ms] (mean, across all concurrent requests)
Transfer rate:          237307.67 [Kbytes/sec] received

ab -kc 500 -n 100000 http://0.0.0.0/html_apc.php
Requests per second:    11795.11 [#/sec] (mean)
Time per request:       42.390 [ms] (mean)
Time per request:       0.085 [ms] (mean, across all concurrent requests) 
Transfer rate:          197199.56 [Kbytes/sec] received

脚本很简单: 的 html_disk.php

$file = file_get_contents('page.html');
echo $file;

html_apc.php

if ($page = apc_fetch('page')) {
  echo 'APC!';
  echo $page;
} else {
  echo 'FILE!';
  $file = file_get_contents('page.html');
  echo $file;
  apc_add('page', $file, 120);
}

第一个脚本加载后,HTML页面应该从共享内存中加载吗?

0 个答案:

没有答案