首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >WordPress站点上的APC碎片

WordPress站点上的APC碎片
EN

Stack Overflow用户
提问于 2012-02-15 11:18:01
回答 1查看 5.9K关注 0票数 3

我最近在一个web服务器(CentOS5.7、PHP5.3、1.5GBRAM)上安装和激活了APC缓存,该服务器主要用于运行WordPress缓存的中等流量(30k唯一访问者/mo)的W3Total站点,该站点设置为使用APC进行数据库和对象缓存(页面,缩小使用磁盘)。

服务器的APC页面显示,始终存在严重的碎片。例如,在重新启动httpd之后,11小时后碎片将达到75%,几天后我已经看到了100%的碎片。我从未见过超过40%的缓存内存被使用,服务器始终以大约400-m的内存运行,1100-m空闲(-/+缓冲区/缓存,正如空闲-m所报告的那样)。因此,造成碎片的似乎并不是缺少内存。

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

  • apc.ttl减少到1800 (从7200)
  • apc.user_ttl设置为0(唯一使用用户缓存的是W3TC,它设置了自己的TTL)
  • W3TC超时时间从180秒增加到7200秒
  • apc.filters阻止计时器

这些变化似乎都没有产生太大的影响,尽管到目前为止,谷歌网站管理员工具所测量的主观性能和页面加载时间似乎都没有受到任何影响。

我该担心这个吗?虽然当前的性能表明情况并非如此,但我宁愿在服务器负载/站点流量上升之前对其进行排序。如果是令人关注的问题,我可以采取哪些步骤来解决呢?

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

代码语言:javascript
复制
; 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

UPDATE I也从W3TotalCache的作者那里得到了张贴在WP论坛上的响应:-

在一些网站上,这种体验并不出人意料。我将在下一个版本中研究缓存逻辑,以提高APC性能。

因此,W3TotalCache似乎是碎片的根本原因。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-02-15 12:53:57

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

优化APC缓存

如果您的服务器上有其他vhost不需要操作码缓存,您可以禁用这些站点的APC。您可以在vhost级别上通过在apc.cache_by_default=0文件中设置apc.ini,并将php_flag apc.cache_by_default On放在wp根目录的.htaccess文件中来完成。这应该是不成体系的原因。

文件中的更改也会导致碎片化。编辑后的文件将被删除,新文件将被添加到缓存中。如果您还没有完成,那么还应该设置apc.stat=0。这将通过不每次检查文件是否被更改来提高整体性能。

如果您不希望want被缓存,您可以创建一个像admin.example.com这样的子域,并且可以访问管理面板。通过这样做,您将能够禁用操作码缓存。这也会减少碎裂。

更新:禁用对象缓存和db缓存有助于减少碎片。Us‘’ng redis或memcached用于对象缓存,APC仅用于操作码缓存解决了这个问题。

票数 5
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/9292330

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档