我在 CentOS 服务器 5 上运行 APC(php 缓存)(每天 13 000 次访问),运行 php 5.3.3、APC 3.1.4 和 4Gb RAM。在过去的几周里,我经历了很多“unable to allocate memory for pool
” 日志中出现错误,并且网站经常会宕机。
我认为问题出在APC上。从统计数据来看,一两个小时后缓存就满了,而且碎片总是跳到 100%。这是我的 apc.ini 配置设置:
apc.cache_by_default 1
apc.canonicalize 0
apc.coredump_unmap 0
apc.enable_cli 0
apc.enabled 1
apc.file_md5 0
apc.file_update_protection 2
apc.filters
apc.gc_ttl 3600
apc.include_once_override 0
apc.lazy_classes 00
apc.lazy_functions 0
apc.max_file_size 1M
apc.mmap_file_mask /dev/zero
apc.num_files_hint 0
apc.preload_path
apc.report_autofilter 0
apc.rfc1867 0
apc.rfc1867_freq 0
apc.rfc1867_name APC_UPLOAD_PROGRESS
apc.rfc1867_prefix upload_
apc.rfc1867_ttl 3600
apc.shm_segments 1
apc.shm_size 512M
apc.slam_defense 1
apc.stat 1
apc.stat_ctime 0
apc.ttl 7200
apc.use_request_time 1
apc.user_entries_hint 0
apc.user_ttl 7200
apc.write_lock 1
从APC统计数据中我可以看到缓存文件的数量非常高(40 000),这是由于phpbb和mediawiki的缓存文件过多所致。我是否必须使用以下方式阻止 APC 缓存此文件apc.filters
?问题有解决办法吗?
您确实应该在生产服务器上设置 apc.stat=0 ,这将阻止 APC 实际访问 IO 检查文件是否已更改。
还设置 apc.slam_defense=0 因为它已被弃用
查看其他选项的文档:http://php.net/manual/en/apc.configuration.php http://php.net/manual/en/apc.configuration.php
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)