我们在一台机器上运行许多网站,
apc.shm = 4G
。但这样的缓存空间不足以缓存所有内容,因此我们设置了apc.ttl= 600
,使得未使用的条目会被清除。但我们无法确定其是否按计划工作。我们看到了约91%的良好缓存命中率,但100%的碎片化非常快。
我们还发现PHP偶尔会无响应,需要重启Apache,但PHP或Apache日志中没有任何记录。在此期间,Apache仍然可以正常提供静态文件。我的直觉告诉我这与APC中的翻转有关。以下是当前的设置:
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 0
apc.lazy_functions 0
apc.max_file_size 1M
apc.mmap_file_mask /dev/zero
apc.num_files_hint 1024
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.serializer default
apc.shm_segments 1
apc.shm_size 4G
apc.slam_defense 1
apc.stat 1
apc.stat_ctime 0
apc.ttl 600
apc.use_request_time 1
apc.user_entries_hint 4096
apc.user_ttl 7200
apc.write_lock 1
有几个问题:
我们修改了
apc.ttl
,但没有同时更改apc.gc_ttl
。降低这个值会帮助更快地清理文件并减少碎片化吗?如果我们将
apc.ttl = 0
,让 APC 在每次缓存填满时都清空并重建,会更好吗?
谢谢您的帮助!