php – APC服务器缓存碎片

前端之家收集整理的这篇文章主要介绍了php – APC服务器缓存碎片前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我在CentOS 5.5上运行带有APC和W3TC的wordpress站点,每天可获得大约10000次网页浏览(包括ajax和WP-Admin).服务器是低级别VPS,最大内存为376MB.

最近我开始得到一些服务器崩溃,我现在可以将其归因于APC(我暂时禁用了它并且崩溃停止了).

重新安装并查看APC图表后,我发现在启动PHP-FPM后几秒钟我们就会遇到很多碎片.在某些情况下,几分钟内可能会发生100%碎片.

当前缓存大小为40MB,由于服务器的内存限制,我有点犹豫不决.

我已经在2小时内在缓存上设置了一个ttl,但考虑到正在发生的碎片数量,我担心这可能太长了,但是如果我将它设置得太短,它将会破坏缓存的整个目的.

我还注意到,当设置userttl大于0时,当调用某些require / include / require_once / include_once函数时,我会遇到大量错误.

任何帮助将不胜感激.

如果在W3 Total Cache安装说明中建议您运行APC 3.0.6,那么您可能会获得潜在的缓存,从而避免错误,从而非常快速地填满您的日志.

卸载APC并使用3.1.7版本(3.1.9是当前稳定版本)进行重建,修复了缓存slam bug和numerous other issues.

运行最新的PHP 5.3.6也会获得更好的结果每个版本在与APC交互时变得更好(当PHP 6出现时它们将完全集成).

另外,请查看配置文件和apc.slam_defense设置,并将其提升到30或40左右.

对于真正的性能提升,将apc.stat设置为0,它将删除检查文件新版本的过程.如果您对网站进行了大量更改,则在缓存过期之前不会更新. (我的用户感到沮丧所以我必须将它设置为1)

setting apc.slam_defense to 75 would
mean that there is a 75% chance that
the process will not cache an uncached
file. So,the higher the setting the
greater the defense against cache
slams. Setting this to 0 disables this
feature.

降低apc.user_ttl,这是W3 Total Cache使用的,它是更动态的东西.保持apc.ttl高,因为这将是你没有真正改变的wordpress核心文件主题文件.

我假设你的设置对象和数据库缓存在W3到APC.对于您的服务器大小,我会将页面缓存设置为磁盘增强.还记得你可以在W3中设置动态内容的ttl.

这是我在带有12G Ram的专用服务器上运行一个非常大的wordpress Multisite.即使内存有限,也不要害怕增加缓存大小.如果需要,您可以随时返回.我的设置为512M,但它的使用时间从未超过120M.

; 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 = 2700
apc.user_entries_hint = 2700
apc.ttl = 7200
apc.user_ttl = 3600
apc.gc_ttl = 600
apc.cache_by_default = 1
apc.slam_defense = 1
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 = 1350
apc.coredump_unmap = 0
apc.stat_ctime = 0
原文链接:https://www.f2er.com/php/139145.html

猜你在找的PHP相关文章