APC Cache Fragmentation Problem

I run APC (php cache) on an average website (13,000 visits per day) on a CentOS 5 server running php 5.3.3 with APC 3.1.4 with 4 GB of RAM. In recent weeks, I have had a lot of " unable to allocate memory for pool " errors in logs, and often the site goes down.

I think the problem is in APC. From the statistics, I see that the cache is full in an hour or two, and fragmentation always goes 100%. These are my apc.ini configuration settings:

 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 00 apc.lazy_functions 0 apc.max_file_size 1M apc.mmap_file_mask /dev/zero apc.num_files_hint 0 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.shm_segments 1 apc.shm_size 512M apc.slam_defense 1 apc.stat 1 apc.stat_ctime 0 apc.ttl 7200 apc.use_request_time 1 apc.user_entries_hint 0 apc.user_ttl 7200 apc.write_lock 1 

From the APC statistics, I see that the number of cached files is very large (40,000), and this is due to the many phpbb and mediawiki cache files. Should I disable APC caching of these files with apc.filters ? Are there any solutions to the problem?

+4
source share
2 answers

You really need to set apc.stat = 0 on your production server and this will prevent the actual switching of APC to IO to check if the file has been modified.

also sets apc.slam_defense = 0 as it is deprecated

Check out the documentation for other parameters: http://php.net/manual/en/apc.configuration.php

+7
source

I think you should set apc.mmap_file_mask = / tmp / apc-yourusernamehere.XXXXXX for the mmap file; make the file mask unique by adding your unique line; XXXXXX (exactly 6 Xs) must remain to allow APC to add a random line OR to set / dev / zero for anonymous mmap if you can free up memory.

I see that you are using / dev / zero, which takes up memory unnecessarily.

+2
source

All Articles