APC使PHP 5.3更慢?

时间:2013-03-11 16:49:26

标签: php apache apc

我最近了解了APC(我知道,我已经迟到了)并决定在我的开发服务器上试用它。我用ApacheBench进行了一些基准测试,令我惊讶的是我发现事情比以前运行

我没有对apc_fetch或其他任何内容进行任何代码优化,但我认为操作码缓存会对其自身产生积极影响吗?

C:\Apache24\bin>ab -n 1000 http://localhost/
This is ApacheBench, Version 2.3 <$Revision: 1178079 $>
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)
Finished 1000 requests


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

Document Path:          /
Document Length:        22820 bytes

Concurrency Level:      1
Time taken for tests:   120.910 seconds
Complete requests:      1000
Failed requests:        95
   (Connect: 0, Receive: 0, Length: 95, Exceptions: 0)
Write errors:           0
Total transferred:      23181893 bytes
HTML transferred:       22819893 bytes
Requests per second:    8.27 [#/sec] (mean)
Time per request:       120.910 [ms] (mean)
Time per request:       120.910 [ms] (mean, across all concurrent requests)
Transfer rate:          187.23 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.4      0       1
Processing:   110  120   7.2    121     156
Waiting:       61   71   7.1     72     103
Total:        110  121   7.2    121     156

Percentage of the requests served within a certain time (ms)
  50%    121
  66%    122
  75%    123
  80%    130
  90%    131
  95%    132
  98%    132
  99%    137
 100%    156 (longest request)

这是我的php.ini的APC部分。除了将默认大小扩展为128MB而不是32位之外,我已将大部分内容保留为默认值。

[APC]
apc.enabled = 1
apc.enable_cli = 1
apc.ttl=3600
apc.user_ttl=3600
apc.shm_size = 128M
apc.slam_defense = 0

我做错了什么,或者我只是需要使用apc_fetch / store才能真正从APC中获益?

感谢你们给予的任何见解。

1 个答案:

答案 0 :(得分:0)

使用默认设置启用APC将使PHP脚本的响应时间明显(至少可以说)差异。您不必使用任何特定的存储/获取功能来从APC中获益。事实上,通常你甚至不需要一个基准来区分它们;只需浏览您的网站即可明显区别。

如果您没有看到任何差异并且您的基准测试没有出现某种错误,那么我建议您开始调试问题(启用错误报告,检查日志等)。