Posted by jvieille on January 3, 2013 at 9:08am
I am trying to tune apc for improving sites performance.
I use cacherouter and set it to redirect all cache tables to apc (see below)
apc stats and data are available for example here:
https://www.see.asso.fr/apc.php
I observe that the fragmentation is high despite a significant memory allocation, and the miss rate is exactly equal to the insert rate for File cache and much more for user cache
Is everything fine, or should I expect better, how?
Thanks for comments, help, suggestions
// CacheRouter
$conf['cache_inc'] = './sites/all/modules/cacherouter/cacherouter.inc';
$conf['cacherouter'] = array(
'default' => array(
'engine' => 'apc',
'prefix' => 'see',
'path' => 'sites/see.shareontheweb.com/files/filecache',
'static' => FALSE,
'fast_cache' => TRUE,
),
'cache_content' => array(
'engine' => 'apc',
'prefix' => 'see',
'path' => 'sites/see.shareontheweb.com/files/filecache',
'static' => FALSE,
'fast_cache' => TRUE,
),
'cache_filter' => array(
'engine' => 'apc',
'prefix' => 'see',
'path' => 'sites/see.shareontheweb.com/files/filecache',
'static' => FALSE,
'fast_cache' => TRUE,
),
'cache_form' => array(
'engine' => 'apc',
'prefix' => 'see',
'path' => 'sites/see.shareontheweb.com/files/filecache',
'static' => FALSE,
'fast_cache' => TRUE,
),
'cache_menu' => array(
'engine' => 'apc',
'prefix' => 'see',
'path' => 'sites/see.shareontheweb.com/files/filecache',
'static' => FALSE,
'fast_cache' => TRUE,
),
'cache_page' => array(
'engine' => 'apc',
'prefix' => 'see',
'path' => 'sites/see.shareontheweb.com/files/filecache',
'static' => FALSE,
'fast_cache' => TRUE,
),
'cache_rules' => array(
'engine' => 'apc',
'prefix' => 'see',
'path' => 'sites/see.shareontheweb.com/files/filecache',
'static' => FALSE,
'fast_cache' => TRUE,
),
'cache_views' => array(
'engine' => 'apc',
'prefix' => 'see',
'path' => 'sites/see.shareontheweb.com/files/filecache',
'static' => FALSE,
'fast_cache' => TRUE,
),
'cache_views_data' => array(
'engine' => 'apc',
'prefix' => 'see',
'path' => 'sites/see.shareontheweb.com/files/filecache',
'static' => FALSE,
'fast_cache' => TRUE,
),
'cache_update' => array(
'engine' => 'apc',
'prefix' => 'see',
'path' => 'sites/see.shareontheweb.com/files/filecache',
'static' => FALSE,
'fast_cache' => TRUE,
),
'cache_mollom' => array(
'engine' => 'apc',
'prefix' => 'see',
'path' => 'sites/see.shareontheweb.com/files/filecache',
'static' => FALSE,
'fast_cache' => TRUE,
),
'cache_block' => array(
'engine' => 'apc',
'prefix' => 'see',
'path' => 'sites/see.shareontheweb.com/files/filecache',
'static' => FALSE,
'fast_cache' => TRUE,
),
'cache_admin_menu' => array(
'engine' => 'apc',
'prefix' => 'see',
'path' => 'sites/see.shareontheweb.com/files/filecache',
'static' => FALSE,
'fast_cache' => TRUE,
),
'cache_advagg' => array(
'engine' => 'apc',
'prefix' => 'see',
'path' => 'sites/see.shareontheweb.com/files/filecache',
'static' => FALSE,
'fast_cache' => TRUE,
),
'cache_advagg_bundle_reuse' => array(
'engine' => 'apc',
'prefix' => 'see',
'path' => 'sites/see.shareontheweb.com/files/filecache',
'static' => FALSE,
'fast_cache' => TRUE,
),
'cache_advagg_css_compress_inline' => array(
'engine' => 'apc',
'prefix' => 'see',
'path' => 'sites/see.shareontheweb.com/files/filecache',
'static' => FALSE,
'fast_cache' => TRUE,
),
'cache_advagg_files_data' => array(
'engine' => 'apc',
'prefix' => 'see',
'path' => 'sites/see.shareontheweb.com/files/filecache',
'static' => FALSE,
'fast_cache' => TRUE,
),
'cache_advagg_js_compress_file' => array(
'engine' => 'apc',
'prefix' => 'see',
'path' => 'sites/see.shareontheweb.com/files/filecache',
'static' => FALSE,
'fast_cache' => TRUE,
),
'cache_advagg_js_compress_inline' => array(
'engine' => 'apc',
'prefix' => 'see',
'path' => 'sites/see.shareontheweb.com/files/filecache',
'static' => FALSE,
'fast_cache' => TRUE,
),
'cache_apachesolr' => array(
'engine' => 'apc',
'prefix' => 'see',
'path' => 'sites/see.shareontheweb.com/files/filecache',
'static' => FALSE,
'fast_cache' => TRUE,
),
'cache_css_emimage_advagg' => array(
'engine' => 'apc',
'prefix' => 'see',
'path' => 'sites/see.shareontheweb.com/files/filecache',
'static' => FALSE,
'fast_cache' => TRUE,
),
'cache_hierarchical_select' => array(
'engine' => 'apc',
'prefix' => 'see',
'path' => 'sites/see.shareontheweb.com/files/filecache',
'static' => FALSE,
'fast_cache' => TRUE,
),
'cache_l10n_update' => array(
'engine' => 'apc',
'prefix' => 'see',
'path' => 'sites/see.shareontheweb.com/files/filecache',
'static' => FALSE,
'fast_cache' => TRUE,
),
'ctools_css_cache' => array(
'engine' => 'apc',
'prefix' => 'see',
'path' => 'sites/see.shareontheweb.com/files/filecache',
'static' => FALSE,
'fast_cache' => TRUE,
),
'ctools_object_cache' => array(
'engine' => 'apc',
'prefix' => 'see',
'path' => 'sites/see.shareontheweb.com/files/filecache',
'static' => FALSE,
'fast_cache' => TRUE,
),
'views_object_cache' => array(
'engine' => 'apc',
'prefix' => 'see',
'path' => 'sites/see.shareontheweb.com/files/filecache',
'static' => FALSE,
'fast_cache' => TRUE,
),
'votingapi_cache' => array(
'engine' => 'apc',
'prefix' => 'see',
'path' => 'sites/see.shareontheweb.com/files/filecache',
'static' => FALSE,
'fast_cache' => TRUE,
),
'boost_cache' => array(
'engine' => 'apc',
'prefix' => 'see',
'path' => 'sites/see.shareontheweb.com/files/filecache',
'static' => FALSE,
'fast_cache' => TRUE,
),
'boost_cache_relationships' => array(
'engine' => 'apc',
'prefix' => 'see',
'path' => 'sites/see.shareontheweb.com/files/filecache',
'static' => FALSE,
'fast_cache' => TRUE,
),the APC config in php.ini is the following
[APC]
apc.cache_by_default = 1
apc.coredump_unmap = 0
apc.enable_cli = 0
apc.enabled = 1
apc.file_update_protection = 2
;apc.filters
apc.gc_ttl = 1800
apc.include_once_override = 0
apc.max_file_size = 10M
;apc.mmap_file_mask
apc.num_files_hint = 5000
apc.report_autofilter = 0
apc.rfc1867 = 0
apc.rfc1867_freq = 0
apc.rfc1867_name = APC_UPLOAD_PROGRESS
apc.rfc1867_prefix = upload_
apc.shm_segments = 1
apc.shm_size = 2G
apc.slam_defense = 40
apc.stat = 0
apc.stat_ctime = 0
apc.ttl = 7200
apc.user_entries_hint = 16384
apc.user_ttl = 7200
apc.write_lock = 1
apc.use_request_time = 1
apc.rfc1867_ttl = 3600
apc.localcache = 0
apc.localcache.size = 2500
;apc.optimization=0
Comments
i dont think the results you
i dont think the results you are quoting are good and i think you can improve it (ideally no fragmenting :).
Files :
from the path it looks like you use a multisite setup ? Bare in mind that once you switch apc on, it will try to cache all php files , ie all contrib in each of multisites, but also for example phpmyadmin or anything else you run on the server. I suggest omiting everything except this 1 site first (you can slowly add stuff). On a server with restricted resources, i would even recommend omitting things like views_ui - generally stuff that isn't used that often and is larger.
User cache :
I cant find the post with recommendations regarding what is appropriate for the APC cache, but definitely not everything. Basically, its smaller stuff that doesn't change so often but is used often, menu router being a good example. Some people wouldn't cache anything in APC, i think it is a good idea (no communication overhead as in other caches), but you have to be selective.
ok, if you can give it 2GB,
ok, if you can give it 2GB, than its probably not a big deal to leave everything in APC, but you will probably have to "warm" the cache first, to see good results. And warm it after every restart of the web server, too. Probably just run wget against it, to make sure everything is cached.
ok, if you can give it 2GB,
ok, if you can give it 2GB, than its probably not a big deal to leave everything in APC, but you will probably have to "warm" the cache first, to see good results. And warm it after every restart of the web server, too. Probably just run wget against it, to make sure everything is cached.
example settings
just in case :) i found the example settings
http://drupal.org/node/945650#comment-4233262
and they say menu is not a good fit for APC (i was probably wrong, sorry - it may also depend on situation)
but if you are willing to give the 2GB, its probably not so important :). warming the cache might be though ...
Yes, I have enough ram, and I
Yes, I have enough ram, and I never got more than 300M used with this config.
Could you elaborate how I can warm-up the cache? a wget of what? from another server?
Thanks
OK, found it - just wget
OK, found it - just wget recursively the site url - crawling in progress.
Is "Miss rate" normal?
- user cache misses about 30%
- cache file seems to miss all inserts
I think the files cache is
I think the files cache is going great by now. If i get it right, you need to have a miss for each insert (that means the first time the file was used). And it looks like the number of misses is not growing and stays close to the number of cached files. I suppose that on second run of wget, the total number of misses shouldn't increase drastically.
The user cache is a different story though - apparently many requests are not even stored for some reason. Could be that they are too large ? The User Cache Entries is not visible for the public, you will have to try and go through it to see the entries that are not cached ...
user cache reasoning and selection
http://www.midwesternmac.com/blogs/jeff-geerling/apc-caching-dramatically
there is an explanation why not everything should go into APC and also about what to put there. you might want to start with those bins first, make sure it works for them and then eventually add other stuff