I am too frustrated with PHP APC caching system and I wanted to remove/disable it completely from my server. I am using PHP with Nginx installed on Debian Squeeze, is there any way of doing it ?
Instead of removing APC, which will cause a massive performance hit, and effectively shoot yourself in the foot..
Try this: in /etc/php5/conf.d/apc.ini:
You can increase
I did this on a server I run, and never ever see Unable to allocate memory for pool errors.
Also check '/etc//php5/apache2/php.ini' for 'extension=apc.so' to outcomment.
If you still have the sources around, you could try to do a
If you didn't install something beside what Squeeze offers, a simple
The solution is to increase memory allocated to APC.
Using a TTL of 0 means that APC will flush all the cache when it runs out of memory. The error don't appear anymore but it makes APC far less efficient. It's a no risk, no trouble, "I don't want to do my job" decision. APC is not meant to be used that way. You should choose a TTL high enough so the most accessed pages won't expire. The best is to give enough memory so APC don't need to flush cache.
Just read the manual to understand how ttl is used : http://www.php.net/manual/en/apc.configuration.php#ini.apc.ttl
You can increase memory allocated by increasing apc.shm_size.
If APC is compiled to use Shared Segment Memory you will be limited by your operating system. Type this command to see your system limit for each segment :
To alocate more memory you'll have to increase the number of segments with the parameter apc.shm_segments.
If APC is using mmap memory then you have no limit. The amount of memory is still defined by the same option apc.shm_size.
If there's not enough memory on the server, then use filters option to prevent less frequently accessed php files to be cached.
But never use a TTL of 0.
Use apc.php to check your config. You'll see what is really allocated and how it is used. The graphs must remain stable after hours, if they are completly changing at each refresh, then it means that your setup is wrong (APC is flushing everything). Allocate 20% than what APC really use as a security margin, and check it on a regular basis.
The default of allowing only 32MB is ridiculously low. PHP was designed when a servers were 64MB and most script were using one php file per page. Nowadays solutions like Magento require more than 10k files (~60Mb in APC). You should allow enough memory so most of php files are always cached. It's not a waste, it's more efficient to keep opcode in ram rather than having the corresponding raw php in file cache. Nowadays we can find dedicated servers with 24Gb of memory for as low as $150, so don't hesitate to allow several GB to APC. I put 2GB out of 24GB on a server hosting 5Magento stores and ~40 wordpress website, APC uses 1.2GB. Count 64MB for Magento installation, 20MB for a Wordpress with some plugins.