Tuning APC to use less RAM
I have a virtual private server that only allows me to use 128MB of RAM. I recently installed APC for PHP and it consumes more than 128MB. My provider wants me to upgrade my account if I don't get that number down. Is there a config option that I can use to set a m开发者_如何学Goaximum on APC?
You can use the apc.shm_size config option. APC Configuration
It seems you need to make changes to apc.shm_segments
and apc.shm_size to change overall memory given to APC.
The goal of APC is to save CPU by spending more ram. You have to allow enough ram so the pages you want to cache will stay cached for next request. 128M is low, a single Wordpress require 20M
To lower the ram required you can :
- merge installations of your scripts if they support multisites and multidomain (Wordpress, Magento...). If you make 10 websites using only one installation you save 90% of ram.
- filter the files cached : use apc.filters to select only the most accessed PHP files and ignore rarely accessed ones.
Fine tuning APC is about giving him enough RAM so it never have to flush cache.
Frank Farmer advice is good. Use apc.php.
It's funny to see everybody answering how to increase memory where you want to actually lower it. And they get point for that ! :)
精彩评论