12

I'm optimizing a Drupal 7 website and I have varnish, memcache and APC all installed and working with their individual Drupal 7 modules. In my settings.php I have the $conf options below.

My question is to get better performance and have all these caches work together well, do I need to add more configuration options?

The module readme's usually assume a single cache system. Are there any tweks needed to get better performance out of running 3 separate caching backends?

// Add Varnish as the page cache handler.
$conf['cache_backends'][] = 'sites/all/modules/varnish/varnish.cache.inc';
$conf['cache_class_cache_page'] = 'VarnishCache';
// Drupal 7 does not cache pages when we invoke hooks during bootstrap.
// This needs to be disabled.
$conf['page_cache_invoke_hooks'] = FALSE;

$conf['cache_backends'][] = 'sites/all/modules/apc/drupal_apc_cache.inc';
$conf['cache_class_cache'] = 'DrupalAPCCache';
$conf['cache_class_cache_bootstrap'] = 'DrupalAPCCache';
//$conf['apc_show_debug'] = TRUE;  // Remove the slashes to use debug mode.

$conf['cache_backends'][] = 'sites/all/modules/memcache/memcache.inc';
$conf['cache_default_class'] = 'MemCacheDrupal';
$conf['cache_class_cache_form'] = 'DrupalDatabaseCache';
  • It seems to me the project page for APC answers your question rather well. – Letharion Mar 11 '12 at 16:36
  • Yes I'm going to take this advice... "Use APC for caches that do not change often and will not grow too big to avoid fragmentation. The default setting of APC will allow you to..", but I still asked this question because it does not account for Varnish too, there may be some specific config changes I'm missing, I will post exactly what I end up using. – user1073319 Mar 11 '12 at 16:38
6

Looks ok to me.

What you can try is play around with Memcache options. There is for example a compression flag but it usally depends on the site if it makes sense to enable it because you then have a higher cpu usage to do the compression/decompression.

I also think that page_cache_invoke_hooks flag is not necessary anymore, see http://drupal.org/node/804864. If you don't need those hooks to run then you can set it, but it's not necessary anymore for Varnish to work.

Using APC cache with multiple webservers means that you run into inconsistencies when clearing caches on one server, so if you do have multiple ones, you probably want to use Memcache for cache and cache_bootstrap as well. I've also had stability issues when using APC cache but I did use it for all caches, which might have been the issue.

  • Is there any problem with using more than one caching system like apc, memcache, etc ? – chrisjlee Apr 4 '13 at 17:39
  • No, you can mix them as you look. You could put a smaller cache bin like 'cache' in APC which is faster but doesn't have that much space usually and put the bigger ones in memcache. – Berdir Apr 5 '13 at 15:15
  • Thanks. Would you know where i can find out how to do that? – chrisjlee Apr 5 '13 at 15:20
  • Each cache bin can be configured to use a specific cache backend, most cache backends come with documentation on how to configure them and you can combine it as you want. – Berdir Apr 8 '13 at 10:29
2

I am running a similar setup with memcache servers and Varnish locally on each web server. I thought that page caching locally with Varnish would not be as effective as using memcache.

I am considering using MongoDB for something since I have it running as well and it is also a shared resource.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.