在上询问此问题serverfault, 并确认W3TC最有可能导致该问题,但我的一些W3TC/Wordpress特定问题无法得到回答。在这里重新发布,因为这个社区有希望更好地回答这些问题。我在下面鼓励他们*
AWS EC2小实例,Apache 2运行WordPress和W3TC。一小时内,我的APC碎片率达到100%。
我的APC设置为:
apc.enabled = 1
apc.shm_segments = 1
apc.shm_size = 100M
apc.optimization = 0
apc.num_files_hint = 512
apc.user_entries_hint = 1024
apc.ttl = 7200
apc.user_ttl = 7200
apc.gc_ttl = 3600
apc.cache_by_default = 1
apc.use_request_time = 1
apc.filters = "apc\\.php$"
apc.mmap_file_mask = "/tmp/apc.XXXXXX"
apc.slam_defense = 0
apc.file_update_protection = 2
apc.enable_cli = 0
apc.max_file_size = 2M
apc.stat = 1
apc.write_lock = 1
apc.report_autofilter = 0
apc.include_once_override = 0
apc.rfc1867 = 0
apc.rfc1867_prefix = "upload_"
apc.rfc1867_name = "APC_UPLOAD_PROGRESS"
apc.rfc1867_freq = 0
apc.localcache = 0
apc.localcache.size = 256M
apc.coredump_unmap = 0
apc.stat_ctime = 0
apc.canonicalize = 1
apc.lazy_functions = 0
apc.lazy_classes = 0
/etc/php.d/apc.ini
More poop can be seen here.
主要是来自here. 经过一些观察后,shm本来打算从这么高的值上缩减下来,但显然这么大的值还不够高。。。。
I found an similar question/answer here. 我确实设置了一些虚拟主机,但它们根本没有受到太多的影响。让用户登录WP的管理面板确实会让事情变得更糟,但这肯定不是罪魁祸首。提问者似乎认为it turns out W3TC is probably causing the problem, 插件作者似乎同意这一点,但除此之外,没有任何有用的细节。Why is it causing the problem? Could this be fixed?
Do I just turn for now and turn off object caching with APC? Is there nothing I can do? Does APC turned on without being used for object caching actually help anything? Would memcache be an ok substitute just for object caching here? Finally, maybe I just shouldn\'t worry so much about the fragmentation?
最合适的回答,由SO网友:Chris_O 整理而成
一般来说,您的apc。shm\\U大小应该是您所看到的最高使用量的两倍。您想尝试阻止缓存已满计数大于0。您可能还想降低一些TTL。我正在与AWS EC2上有5台VHOST的人合作,我们必须提高apc。shm\\U大小为512M,以防止100%碎片。我也有更好的结果设置apc。出于某种原因,使用WordPress将mmap\\u file\\u掩码设置为/dev/zero。
; configuration for php apc module
extension = apc.so
apc.enabled = 1
apc.shm_segments = 1
apc.shm_size = 512M
apc.optimization = 0
apc.num_files_hint = 512
apc.user_entries_hint = 1024
apc.ttl = 0
apc.user_ttl = 0
apc.gc_ttl = 600
apc.cache_by_default = 1
apc.filters = "apc\\.php$"
apc.slam_defense = 0
apc.use_request_time = 1
apc.mmap_file_mask = /dev/zero
apc.file_update_protection = 2
apc.enable_cli = 0
apc.max_file_size = 2M
apc.stat = 1
apc.write_lock = 1
apc.report_autofilter = 0
apc.include_once_override = 0
apc.rfc1867 = 0
apc.rfc1867_prefix = "upload_"
apc.rfc1867_name = "APC_UPLOAD_PROGRESS"
apc.rfc1867_freq = 0
apc.localcache = 1
apc.localcache.size = 512
apc.coredump_unmap = 0
apc.stat_ctime = 0
另一个问题是,您的页面每次加载大约运行170个数据库查询。一些代码优化将教训apc的负载。
您可以尝试memcached,但我已经进行了并排比较,apc总是更快。另一个选项是禁用w3TC中的db缓存并优化MySql查询缓存。并确保您使用的是查询缓存(在安装MySql时默认为关闭)。
编辑:
您使用的是非常过时的apc版本。升级到3.1.9或3.1.10也会有所帮助。