APC + Filecache + DB cache bin configuration

Public

This is a settings file that I reference in all my settings files so that I have a better optimized Drupal Out of the box. $conf['cache_prefix'] is then used in the site specific settings.php file which is the 2nd file included

Get raw version
php
  1. <?php
  2. # APC cache backend
  3. #$conf['apc_show_debug'] = TRUE;
  4. $conf['cache_backends'][] = 'sites/all/modules/apc/drupal_apc_cache.inc';
  5. # APC as default container, others are targeted per bin
  6. #$conf['cache_default_class'] = 'DrupalAPCCache';
  7. # APC as default, so these can be commented out
  8. $conf['cache_class_cache'] = 'DrupalAPCCache';
  9. $conf['cache_class_cache_admin_menu'] = 'DrupalAPCCache';
  10. $conf['cache_class_cache_block'] = 'DrupalAPCCache';
  11. $conf['cache_class_cache_bootstrap'] = 'DrupalAPCCache';
  12. $conf['cache_class_cache_entity_file'] = 'DrupalAPCCache';
  13. $conf['cache_class_cache_entity_og_membership'] = 'DrupalAPCCache';
  14. $conf['cache_class_cache_entity_og_membership_type'] = 'DrupalAPCCache';
  15. $conf['cache_class_cache_field'] = 'DrupalAPCCache';
  16. $conf['cache_class_cache_menu'] = 'DrupalAPCCache';
  17. $conf['cache_class_cache_libraries'] = 'DrupalAPCCache';
  18. $conf['cache_class_cache_token'] = 'DrupalAPCCache';
  19. $conf['cache_class_cache_views'] = 'DrupalAPCCache';
  20. $conf['cache_class_cache_path_breadcrumbs'] = 'DrupalAPCCache';
  21. $conf['cache_class_cache_path'] = 'DrupalAPCCache';
  22.  
  23. # Filecache for ones that are big and don't change much
  24. $conf['cache_backends'][] = 'sites/all/modules/filecache/filecache.inc';
  25. # use this for file systems that don't have shared memory
  26. #$conf['filecache_directory'] = 'PATH_TO_PRIVATE_FILES/_filecache/' . $conf['cache_prefix'];
  27. # hit file system in the shared memory portion for faster access
  28. #$conf['filecache_directory'] = '/dev/shm/drupal_filecache/' . $conf['cache_prefix'];
  29. #$conf['cache_default_class'] = 'DrupalFileCache';
  30. $conf['cache_class_cache_entity_user'] = 'DrupalFileCache';
  31. $conf['cache_class_cache_advagg_aggregates'] = 'DrupalFileCache';
  32. $conf['cache_class_cache_advagg_info'] = 'DrupalFileCache';
  33. $conf['cache_class_cache_update'] = 'DrupalFileCache';
  34. $conf['cache_class_cache_views_data'] = 'DrupalFileCache';
  35. $conf['cache_class_cache_page'] = 'DrupalFileCache';
  36. $conf['cache_class_cache_display_cache'] = 'DrupalFileCache';
  37. $conf['cache_class_cache_entity_node'] = 'DrupalFileCache';
  38.  
  39. # Default DB for the ones that change too frequently and are small
  40. $conf['cache_default_class'] = 'DrupalDatabaseCache';
  41. # THIS MUST BE SERVED FROM DB FOR STABILITY
  42. $conf['cache_class_cache_form'] = 'DrupalDatabaseCache';

end of the setting.php file I use (this uses a setup called DSLM hence the path below is probably weird compared to what you'd use)

Get raw version
php
  1. $conf['cache_prefix'] = 'your_site_prefix';
  2.  
  3. require_once DRUPAL_ROOT . '/../../shared/drupal-7.x/shared_settings.php';

Comments

Spleshka's picture

Storing cached data in the APC has poor impact on memory fragmentation. This leads to the performance decrease when using APC also as an opcode cache tool.

Ryan Aslett's picture

@Speshka : thats only if you've misconfigured APC by trying to stuff too much into it without giving it enough RAM.

btopro's picture

Both are correct :). I get around this problem through proper tuning, minimizing what I put in APC to expensive operations that almost never change, and then doing a nightly apache restart which dumps APC. I realize the last option isn't for everyone since technically that would be planned outage every night for a few seconds.

btopro's picture

I updated the list with some improvements from real world testing / balancing cache bin performance with system stability on a dual-core, 4 GB ram RHEL VMware VM on a beefy Dell blade server.