Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Asked this question at serverfault, and got confirmation that W3TC is most likely causing the issue, but several of my more W3TC/Wordpress specific issues weren't able to be answered. Reposting here as this community had hopefully answer those better. I emboldened them below.*

AWS EC2 Small instance, Apache 2 running WordPress and W3TC. Within an hour, my APC fragmentation hits 100%.

My APC settings are:

apc.enabled = 1
apc.shm_segments = 1
apc.shm_size = 100M
apc.optimization = 0
apc.num_files_hint = 512
apc.user_entries_hint = 1024
apc.ttl = 7200
apc.user_ttl = 7200
apc.gc_ttl = 3600
apc.cache_by_default = 1
apc.use_request_time = 1
apc.filters = "apc\.php$"
apc.mmap_file_mask = "/tmp/apc.XXXXXX"
apc.slam_defense = 0
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 = 0
apc.localcache.size = 256M
apc.coredump_unmap = 0
apc.stat_ctime = 0
apc.canonicalize = 1
apc.lazy_functions = 0
apc.lazy_classes = 0
/etc/php.d/apc.ini

More poop can be seen here.

Mostly cribed settings from here. The shm was meant to be whittled down from such a high value after some observation, but apparently such a large value isn't even high enough....

I found an similar question/answer here. I do have some virtual hosts setup, but they aren't being touched much at all. Having users logged into the admin panel of WP does make things worse, but that's certainly not the main culprit. The question asker seems to suggest that it turns out W3TC is probably causing the problem, which the plugin author seems to agree with, but there aren't any helpful details beyond that. Why is it causing the problem? Could this be fixed?

Do I just turn for now and turn off object caching with APC? Is there nothing I can do? Does APC turned on without being used for object caching actually help anything? Would memcache be an ok substitute just for object caching here? Finally, maybe I just shouldn't worry so much about the fragmentation?

share|improve this question

closed as off-topic by Pieter Goosen, G. M., Mark Kaplun, ialocin, birgire Aug 25 at 16:02

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Your question should be specific to WordPress. Generic PHP/JS/HTML/CSS questions might be better asked at Stack Overflow or another appropriate site of the Stack Exchange network. Third party plugins and themes are off topic." – Pieter Goosen, G. M., Mark Kaplun, ialocin, birgire
If this question can be reworded to fit the rules in the help center, please edit the question.

1  
May I suggest a simple solution? Please move onto memcached plus batcache setup. As you are in a VPS with enough memory (EC2 small instance), whatever you'd like to achieve with W3TC (apart from caching), can be done without it too. I'm sorry, I couldn't answer your original question on APC. –  Pothi Apr 5 '12 at 2:46
    
Indeed, worth remembering when going too far down the W3TC rabbit hole. –  two7s_clash Apr 8 '12 at 1:58

1 Answer 1

up vote 1 down vote accepted

Generally speaking your apc.shm_size should be double your highest seen used amount. You want to try and prevent your cache full count from being higher than 0. You might want to also lower some of your ttls. I'm working with someone on AWS EC2 with 5 vhosts and we had to raise apc.shm_size to 512M to prevent 100% fragmentation. I also have better results setting apc.mmap_file_mask to /dev/zero with WordPress from some reason.

enter image description here

; 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 = 512
apc.user_entries_hint = 1024
apc.ttl = 0
apc.user_ttl = 0
apc.gc_ttl = 600
apc.cache_by_default = 1
apc.filters = "apc\.php$"
apc.slam_defense = 0
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 = 512
apc.coredump_unmap = 0
apc.stat_ctime = 0

Another problem is your pages are running around 170 database queries per load. Some code optimization will lesson the load on apc.

You can try memcached but I've done side by side comparisons and apc is always faster. Another option is to disable db caching in w3TC and tune MySql query cache. And make sure you are using query cache (It's off by default when you install MySql).

Edit:

Your using a really outdated version of apc. Upgrading to 3.1.9 or 3.1.10 will also help.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.