2

我最近了解了 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 中受益?

感谢你们提供的任何见解。

4

1 回答 1

0

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

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

于 2013-03-11T20:47:10.487 回答