Changes required on "Installing Alternative PHP Cache (APC)"

bokan

Verified User
Joined
Jul 3, 2011
Messages
19
I installed APC cache using this help :
http://help.directadmin.com/item.php?id=400

It recomend to use APC with these parameters :
apc.shm_size=128M
apc.ttl=7200
apc.user_ttl=7200

Using 128M is very low, especially with a TTL of 7200. After some minutes you'll get error :
Warning: require_once() [function.require-once]: Unable to allocate memory for pool. in /path/to/file
http://stackoverflow.com/questions/...-require-once-unable-to-allocate-memory-for-p

If TTL is set to 0 this error don't show, but APC won't be efficient as it will flush the whole cache when it run out of memory.

32Mb was ok for old style websites with simple php scripts, but nowadays CMS are huge php solutions with hundred files and complex code. A single installation of Wordpress require more than 20MB of cache, Magento more than 50MB.
On my server with ~30 Wordpress, 2 Joomla and 6 Magento, APC is using 1.2GB out of 2Gb allocated (just code cache, no user cache is used)

APC is about using memory to save CPU cycles. Most servers with APC have low amount of memory dedicated to APC so it have to flush it's cache every minutes. It's worse than not having APC at all.

I think this should be added :
----
To find the amount of memory required on your server, download http://pecl.php.net/get/APC extract apc.php, host it on your server and watch it. There you have a nice diagram how your cache usage look like. You should allow enough memory to APC so it has 10%-20% free after few hours running (so all pages have been cached). Opcode is times bigger than PHP source code, APC could require GBs of ram on shared servers.

APC could use either SHM or MMAP memory. Both are set with the apc.shm_size option.
Size of Shared segments (SHM) is limited by the OS if you can't increase it, increase the number of segment with apc.shm_segments.

Big scripts like Magento require to increase the max file size to 20MB (apc.max_file_size=20M)
----
 
Last edited:
Back
Top