Proper way to make Cacherouter-APC, Boost work with Aegir (multisite in general) ?

Events happening in the community are now at Drupal community events on www.drupal.org.
playfulwolf's picture

Hi,

Playing with Aegir - it is a great tool, but want to make it on steroids: use boost Boost and Cacherouter+APC as an user object cache for all sites. I will not touch Varnish for now.
What is the proper way to make config that works? Problem is, that I am changing "platforms" on Aegir rapidly and moving "sites" between them often, but haven't found the way to configure them globally.

Thank you for your thoughts.

Comments

Provision boost support

mikeytown2's picture

Never used it, but I'm sure it will be helpful
http://drupal.org/project/provision_boost

thank you, never saw that

playfulwolf's picture

thank you, never saw that module

drupal+me: jeweler portfolio

If you use memcache

kbahey's picture

If you use the memcache module, then there is a key prefix that you can add to the settings.php of each site, and that would make the cache unique, for example:

$conf['memcache_key_prefix'] = 'site1-live';
$conf['cache_inc']           = './sites/all/modules/contrib/memcache/memcache.inc';
$conf['memcache_servers']    = array('127.0.0.1:11211' => 'default');

You can even make that automatically derived from the host name:

$conf['memcache_key_prefix'] = $_SERVER['HTTP_HOST'];
$conf['cache_inc']           = './sites/all/modules/contrib/memcache/memcache.inc';
$conf['memcache_servers']    = array('127.0.0.1:11211' => 'default');

And starting with memcache 6.x-1.5, you only need one bin, so the above would work for any site, no matter how many cache_* tables it has.

Drupal performance tuning, development, customization and consulting: 2bits.com, Inc..
Personal blog: Baheyeldin.com.

Use dir name for key prefix

mikeytown2's picture

<?php
$conf
['memcache_key_prefix'] = array_pop(explode('/', conf_path()));
?>

http://api.drupal.org/api/function/conf_path/6
I have to use something like this because of domain access. I'll give the exact code that I use tomorrow, it's domain access & symlink friendly.
http://drupal.org/project/domain

Yes, good catch with

omega8cc's picture

Yes, good catch with conf_path() used as a key_prefix.

memcache key prefix

mikeytown2's picture

This should work with domain access & symlinks.

<?php
$conf
['memcache_key_prefix'] = array_pop(explode('/', str_replace("\\", '/', realpath(conf_path()))));
?>

I also name the databases similar to this replacing the . with a _. All my settings.php's are exactly the same, so I have an include file in 1 location to keep all the settings since all of my multisites are the same for the most part.

thank you, Khalid, but I am

playfulwolf's picture

thank you, Khalid, but I am looking for some general config, to write in global.inc, and also do not have plenty of RAM, so need to stick with APC/eaccelerator + Boost.

drupal+me: jeweler portfolio

Put your custom code in

omega8cc's picture

Put your custom code in global.inc, not in settings.php, since settings.php will be overwritten with every site re-verify, migration etc. The global.inc file include path you can find at the end of generated by Aegir settings.php file.

Example code, compatible with Domain Access module, Drupal for Facebook and cache module, using failover cache chain, redis, memcached and db:

http://omega8.cc/dev/example-global.inc.txt

It has also automatic switch to disable caching for dev sites and even allows to configure db prefix per site.

HTH ~Grace

redis?

playfulwolf's picture

Are you using redis on this example config? never heard running it with drupal, how can performance be compared?

drupal+me: jeweler portfolio

?

playfulwolf's picture

the config you provided is an overkill, I could not decipher it...

in my case it is like:

<?php
# global settings.php
$thishost = $_SERVER[HTTP_HOST];
if (
file_exists('./sites/'.$thishost.'/modules/cacherouter/cacherouter.inc')) {
$conf['cache_inc'] = './sites/'.$thishost.'/modules/cacherouter/cacherouter.inc';
$conf['cacherouter'] = array(
 
'default' => array(
   
'engine' => 'apc',
   
'servers' => array(),
   
'shared' => TRUE,
   
'prefix' => '$thishost',
   
'path' => 'sites/default/files/filecache',
   
'static' => FALSE,
   
'fast_cache' => TRUE,
  ),
);}
?>

How to transfer proper platform for this to work? Have cacherouter module installed on /var/aegir/platforms/platform-name/sites/all/modules/cacherouter/ , it is available for all sites on the same platform.

drupal+me: jeweler portfolio

wow!

playfulwolf's picture

cadcherouter with apc works with ou-of-the box settings - god bless mod_rewrite and aegir devs!!!

drupal+me: jeweler portfolio

Boost works with Aegir out of

omega8cc's picture

Boost works with Aegir out of the box, you even don't need provision_boost module if you will create standard boost cache dirs in every platform root:

$ cd /path/to/platform/root/dir
$ mkdir -p ./cache/perm
$ mkdir -p ./cache/normal
$ chmod 777 -R ./cache
$ chown -R www-data:www-data ./cache

And use not only APC, but also Nginx with PHP-FPM if you want it on steroids =)
See also: http://groups.drupal.org/nginx

HTH ~Grace

thank you, this Boost is the

playfulwolf's picture

thank you, this Boost is the first thing to try.

drupal+me: jeweler portfolio

Trying to configure Boost on Aegir

socialnicheguru's picture

Hi Grace,

You said "Boost works with Aegir out of the box".

But when I install Boost on Aegir it says ".htaccess file does not contain or match the boost specific rewrite rules, or the rewrite rules have changed, due to new settings, and they need to be updated. Get the rules:"

I thought it would be a good idea to install Boost for static pages. I assume the rewrite rules in the .htaccess file that boost asks me to add will allow static pages to go through Boost. Is that the case?

Where do I put the rewrite rules?

I have:
apache2
advcache working with patches applied
authcache
cacherouter
APC installed

I also have
css_gzip
javascript_aggregator

Images and sessions:
css_emfield
session_expire

Barracuda and Octopus for

omega8cc's picture

Barracuda and Octopus for Nginx based Aegir Hosting System have it all enabled and Boost ready out of the box.

When you are using Apache with Aegir, you need to add required rewrites in the .htaccess file. Boost comes with ready to use .htaccess files and even convenient generator for that file. You will need to use provision submodule to have it configured on the fly for Apache.

Feel free to ask questions regarding Apache based setup (btw: I never used Aegir or Boost with Apache since I dropped Apache many years ago) on the Aegir community website we have now: http://community.aegirproject.org

If you use cacherouter-APC

jmseigneur's picture

If you use cacherouter-APC for the bins default, anonymous pages should also be cached by cacherouter-APC, shouldn't they?

If Boost is added on top of cacherouter-APC, how do you specify that anonymous pages must be cached by Boost only and not cacherouter-APC?

Caching anonymous pages with cacherouter-APC should be faster than with Boost because Boost caches in files and cacherouter-APC in memory, shouldn't it?

You turn off core page

brianmercer's picture

You turn off core page caching by setting "Caching Mode:" to "Disabled" on admin/settings/performance. This is the default for using Boost.

Boost files served directly by a webserver (especially an optimized one like nginx, cherokee, lighttpd, etc.) are going to be several times faster than cacherouter-APC because no PHP code is involved. (Also see http://technosophos.com/content/53900-speedup-nginx-drupal-and-memcache-... where nginx serves files directly from memcached.)

And don't forget that modern unix systems cache files in memory as well. Linux (or BSD, etc.) uses unused RAM to cache files retrieved from the file system. It's quite good at it.

If you're using a single server where the data set is larger than the memory, file caching is usually better than anything you could write for filling and clearing items from an APC or memcached system, and much faster than anything you could write in PHP. APC is limited to a single server as well. Now if you're using APC/memcached for the other _cache tables, not page_cache, those can fit comfortably in available memory, so it's all good.

The point of memcached is that it is not limited to the file system of one server. If you're Facebook and you can have hundreds of servers running memcached so that almost all of your page data fits into memory.

Or, if you're using

gchaix's picture

Or, if you're using Pressflow: "External cache".

Now if you're using

jmseigneur's picture

Now if you're using APC/memcached for the other _cache tables, not page_cache, those can fit comfortably in available memory, so it's all good.

I know how to configure cacherouter-APC for specific cache tables and there's a default caching set by adding the following to settings.php

$conf['cache_inc'] = './sites/all/modules/contrib/cacherouter/cacherouter.inc';
$conf['cacherouter'] = array(
'default' => array(
'engine' => 'apc',
'servers' => array(),
'shared' => TRUE,
'prefix' => '',
'path' => 'sites/default/files/filecache',
'static' => FALSE,
'fast_cache' => TRUE,
),
);

However, I don't know how to disable cacherouter for page_cache only due to the default caching method set above. Would you hav e an idea on how to disable cacherouter for page_cache only?

Many thanks for your help. BTW, I had used your php5-fpm package with Nginx that work well but I had to revert back to Apache due to incompatibility of many Drupal contributed modules with PHP5.3 and non available php5-fpm package for PHP5.2

Set "Caching Mode:" to

brianmercer's picture

Set "Caching Mode:" to "Disabled" at http://yoursite.com/admin/settings/performance. Or "External" if you're using Varnish or something similar and want to send Cache-control headers.

To verify and monitor your APC use: unzip /usr/share/doc/php-apc/apc.php.gz and copy it to your webroot. Edit it to give it a password, and then view it through the web. It will show you your memory use overall, hit rate, and also let you browse the system (opcode) cache and the user cache entries to see what you're caching. You can verify that there are no page_cache entries in there.

Thanks for the feedback on

brianmercer's picture

Thanks for the feedback on the php5-fpm package. I hear ya on the 5.3 issues. Finding and maintaining a bunch of extra patches is inconvenient.

socialnicheguru's picture

has anyone found issues with autcache/cacherouter and either cloning or verifying sites on aegir beta 2?

I described the problem here.

http://community.aegirproject.org/node/228

High performance

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: