php – WordPress网站上的APC缓存碎片

我最近在Web服务器(Centos 5.7,PHP 5.3,1.5Gb RAM)上安装并激活了APC缓存,该服务器主要用于中等流量(30k唯一访问者/ mo)运行W3Total Cache的WordPress站点,该站点设置为使用APC数据库和对象缓存(页面,缩小使用磁盘).

服务器的APC信息页面显示存在严重的碎片.例如,重新启动httpd后,11小时后碎片率高达75%,而且几天后我已经看到它达到100%.在任何时候我都没有看到超过大约40%的高速缓存使用,并且服务器始终运行在大约400Mb的内存,1100Mb空闲( – / buffers / cache,由free -m报告).所以它似乎没有导致碎片的内存不足.

我从默认的APC和W3TC配置开始,尝试了以下更改的各种组合: –

> apc.ttl减少到1800(从7200)
> apc.user_ttl设置为0(唯一使用用户缓存的是W3TC并设置自己的TTL)
> W3TC超时从180秒增加到7200秒
> apc.filters阻止timthumb

这些变化似乎没有太大的区别,尽管到目前为止,Google网站站长工具测量的主观性能和页面加载时间似乎都没有受到任何影响.

我应该担心吗?虽然目前的性能表明没有,但我宁愿在服务器负载/站点流量上升之前对其进行排序.如果引起关注,我可以采取哪些措施来解决?

编辑:-
这是完整的apc.ini配置文件: –

; Enable apc extension module
extension = apc.so

; Options for the APC module version >= 3.1.3
; See http://www.php.net/manual/en/apc.configuration.php

; This can be set to 0 to disable APC. 
apc.enabled=1
; The number of shared memory segments to allocate for the compiler cache. 
apc.shm_segments=1
; The size of each shared memory segment, with M/G suffixe
apc.shm_size=256M
; A "hint" about the number of distinct source files that will be included or 
; requested on your web server. Set to zero or omit if you're not sure;
apc.num_files_hint=1024
; Just like num_files_hint, a "hint" about the number of distinct user cache
; variables to store.  Set to zero or omit if you're not sure;
apc.user_entries_hint=4096
; The number of seconds a cache entry is allowed to idle in a slot in case this
; cache entry slot is needed by another entry.
apc.ttl=7200
; use the SAPI request start time for TTL
apc.use_request_time=1
; The number of seconds a user cache entry is allowed to idle in a slot in case
; this cache entry slot is needed by another entry.
apc.user_ttl=0
; The number of seconds that a cache entry may remain on the garbage-collection list. 
apc.gc_ttl=3600
; On by default, but can be set to off and used in conjunction with positive
; apc.filters so that files are only cached if matched by a positive filter.
apc.cache_by_default=1
; A comma-separated list of POSIX extended regular expressions.
apc.filters="-.[omitted]/timthumb.php$"
; The mktemp-style file_mask to pass to the mmap module 
apc.mmap_file_mask=/tmp/apc.XXXXXX
; This file_update_protection setting puts a delay on caching brand new files.
apc.file_update_protection=2
; Setting this enables APC for the CLI version of PHP (Mostly for testing and debugging).
apc.enable_cli=0
; Prevents large files from being cached
apc.max_file_size=1M
; Whether to stat the main script file and the fullpath includes.
apc.stat=1
; Vertification with ctime will avoid problems caused by programs such as svn or rsync by making 
; sure inodes havn't changed since the last stat. APC will normally only check mtime.
apc.stat_ctime=0
; Whether to canonicalize paths in stat=0 mode or fall back to stat behaviour
apc.canonicalize=0
; With write_lock enabled, only one process at a time will try to compile an 
; uncached script while the other processes will run uncached
apc.write_lock=1
; Logs any scripts that were automatically excluded from being cached due to early/late binding issues.
apc.report_autofilter=0
; RFC1867 File Upload Progress hook handler
apc.rfc1867=0
apc.rfc1867_prefix =upload_
apc.rfc1867_name=APC_UPLOAD_PROGRESS
apc.rfc1867_freq=0
apc.rfc1867_ttl=3600
; Optimize include_once and require_once calls and avoid the expensive system calls used.
apc.include_once_override=0
apc.lazy_classes=0
apc.lazy_functions=0
; Enables APC handling of signals, such as SIGSEGV, that write core files when signaled. 
; APC will attempt to unmap the shared memory segment in order to exclude it from the core file
apc.coredump_unmap=0
; Records a md5 hash of files. 
apc.file_md5=0
; not documented
apc.preload_path

更新我也是posted on WP forums并得到了W3TotalCache作者的回复: –

That experience is not unexpected on some sites. I will be working on
the caching logic in the next release to improve APC performance.

所以似乎W3TotalCache是​​碎片化的根本原因.

解决方法:

尝试增加APC使用的段大小.仅使用一个细分.还可以从您创建的子域访问wp管理界面.

Optimize APC Caching

如果您的服务器上还有其他不需要操作码缓存的虚拟主机,则可以为这些站点禁用APC.你可以在vhost级别上通过在apc.ini文件中设置apc.cache_by_default = 0来完成它,并将php_flag apc.cache_by_default打开到wp根目录的.htaccess文件中.这应该是分裂的原因.

文件中的更改也可能导致碎片.将删除已编辑的文件,并将新文件添加到缓存中.如果你还没有,你还应该设置apc.stat = 0.这样可以通过不检查文件是否每次都进行检查来提高整体性能.

如果您不希望缓存WP Admin,则可以创建admin.example.com等子域,并且可以访问管理面板.通过这样做,您将能够禁用操作码缓存.这也将减少碎片.

更新:
禁用对象缓存和数据库缓存有助于减少碎片.用于对象缓存的us’ng redis或memcached以及仅用于操作码缓存的APC解决了这个问题.

原文地址:https://codeday.me/bug/20190902/1791152.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


我想将wordpress的默认接口路由改掉,愿意是默认的带一个 wp-json,我想换成 api,直接简单明了。默认路由https://www.xxzhuti.com/wp-json/wp/v2/posts/1新的路由https://www.xxzhuti.com/api/wp/v2/posts/1路由修改wordpress提供了一个钩子来修改 wp-json 的地址,代码入汛function r
wordpress自定义分类法之后,我看到链接都自动在后面添加了一个斜杠,如下图所示打开链接后都是先从一个链接301后到另外一个链接,我这个纳闷,然后一顿找原因,最后竟然是因为固定链接看我后台的固定链接是 /%post_id%/ 这么写的,然后每次都会301自动跳转。正确的写法是 /%post_id%.html 这样写才不会301跳转。一个小问题,往往一个小问题就会折腾好长时间,在这记录一下吧..
事情是这样的,我用 get_post_type 函数创建了一个自定义分类法类型,然后自定义了文件的访问路径代码如下。function tblog_chat_template( $template_path ){    if ( get_post_type() == 'aichat' ) {         if ( is_single() )         {             $temp
最近网站莫名其妙的被顶上了,过一个多小时,就注册一个账号,虽然不多,但是也挺烦,时间一长垃圾注册的就多了。由于我前台把注册关掉了,只允许用第三方登录,经过查找发现是通过后台注册的,后台无须邮箱验证即可注册,也是就想着在后台加个验证码。效果如下实现方法一将下面的代码加入到 function.php 中,刷新页面就会看到。//WordPress新用户注册随机数学验证码function add_s...
最近服务器要到期了,就想着把网站转移到另外一台服务器,本来打算要续费的,但是腾讯云的服务器有了新的规定,域名必须在腾讯云备案才能使用,在别的地方备案的域名需要转到腾讯云,在腾讯云在走一遍备案流程,若是备案简单,时间短也就无所谓了,就转一下,可是这个备案大家也知道,至少得一个月,于是就只能放弃腾讯云了,将站点转回备案的阿里云,以后就用阿里云了,贵点就贵点吧。这不网站迁移过去了,死活图片不显示,各..
今天在写wordpress的接口,然后碰到个奇怪的问题,怎么访问都提示 rest_no_route 的错误,然后就一直跟踪代码,终于找到原因所在。报错信息{'code': 'rest_no_route','message': '未找到匹配URL和请求方式的路由。','data': {'status': 404}}原因分析register_rest_route( string $namespace,
今天看到群友突然滴滴滴的找我QQ,好像出什么大事情一样。原来他由于误操作导致网站文章被删除。
今天遇到一个网友提示网站访问速度比较慢,然后通知日志看到有他的网站WordPress默认登录地址wp-login.php一直在被爬虫抓取,因为是有被破解后台账户信息,导致的占用数据库资源使得网站资源带宽不足后访问降低导致
今天老左在帮助客户升级WordPress的时候我看他网站也比较简单就直接在后台手工升级的。升级后打开网站有出现"There has been a critical error on your website."的错误提示。
我们在使用WordPress搭建的网站是否有留意查看源代码的时候看到标题中的原本"-",被转义成"&#8211"。其实这样并不影响用户阅读体验和搜索引擎,搜索引擎在收录后也会反向转义的。就是感觉看
WordPress默认是无法上传.webp格式的文件,如果要上传需要对上传文件限制进行解除后才能上传。
GTranslate 是一个流行的翻译插件,在免费和付费版本中提供不同的体验。 使用免费版本,您可以轻松提供任何语言的动态翻译,而付费版本提供可索引、可编辑的翻译版本,就像 Weglot 一样。
时下主流的浏览器都自带了广告屏蔽功能,还有ADSafe、ADB等软件插件,不断更新,屏蔽网站代码!
您是否正在寻找可用于显示数据的 WordPress 表格插件? WordPress 表格插件可让您以表格格式存储和呈现数据,以方便访问者阅读。
wordPress数据库除了本身的表以外,部分插件会增加表来存储数据。如果插件已经删除了,这些插件生成的表还在数据库中,那么怎么删除呢?
WordPress几乎是世界上最安全的开源程序,但其后台登录注册的地址始终是众所周知的,所以不少人觉得隐藏WordPress的登录地址后可能会更加安全。下面浩子就针对这个问题来简单说明一下方法。WordPress隐藏后台登录地址
自 WordPress 5.8 正式版发布 以后,后台的小工具就默认是块编辑器的界面样式,很多老用户还没有来得及学习就一脸茫然了,今天浩子就来教大家如何恢复WordPress经典小工具。
您想用您的语言翻译 WordPress 插件吗?许多 WordPress 插件是完全可翻译的,世界上任何人都可以轻松翻译。在本文中,我们将向您展示如何轻松地将 WordPress 插件翻译成您的语言(无需任何代码)。
WordPress新手不清楚WordPress调试模式怎么开启,今天来教大家认识和开启。什么是WordPress的调试模式
最近不少用户反馈说WordPress后台的外观-自定义点开后直接报错,错误信息如下: