Boosting Drupal / Open Atrium with Memcache and Authcache

25 Feb 2012

Joris Snoek - Business Dev
+31 (0)20 - 261 14 99

Copyright image, see: http://openatrium.com/about

Notes

I write my technical articles in English, so the whole world can enjoy it. I also documented this blog on https://community.openatrium.com/documentation-en/node/3882

The Drupal Open Atrium intranet system

Open Atrium is a Drupal based intranet out of the box, it's an amazing system. But when installed on a 'vanilla' hosting platform and used heavily, it can be experiences as kind of slow. Since the latest updates the performance increased out of the box. But you can always boost it more, so you can use it with thousands of users and browse blazing fast.

Commercial note

We provide an 'instant Open Atrium in the cloud': www.OpenLucius.nl

Boosting Drupal Open Atrium

Drupal is a master in scaling with help of all kinds of caching mechanisms. Thus is Open Atrium. In this case with help of Drupal Authcache module and Memcache. Here is how we got the system boosted.

Installation

ul>

  • Install Memcache API in Drupal Open Atrium
  • Install Authcache
  • Install Cacherouter
  • Configuration

    Configure these palls in settings.php as described on their project pages. For example:

    $conf['memcache_key_prefix'] = 'demo';

    $conf['cache_inc'] = './sites/all/modules/contrib/authcache/authcache.inc';

    $conf['cacherouter'] = array(
      'default' => array(
      'engine' => 'memcache',
      'servers' => array('localhost:11211'),
      'shared' => TRUE,
      'prefix' => 'demo',
      'path' => '../clients/demo/files/authcache',
      'static' => FALSE,
      'fast_cache' => TRUE,
      ),
    );

    Configuration Authcache

    We came across a 'validation error' when using the file upload system and Authcache in place. To fix this, we needed to hack the core of 'upload' module in a dirty filthy way that won't make sense. Obviously, that's a big *ss no go. So we needed to exclude the pages where the file upload is used: these are all node pages. We alse needed to exclude the 'members' page, else adding of members to a group wouldn't work.

    So we had to configure the cache exluded pages at admin/settings/performance/authcache/pagecaching:

    admin*
    user
    */node/add/

    /node//edit
    /node//track
    tracker
    */comment/edit

    civicrm
    cart

    /ajax/
    /autocomplete/
    ajax_comments
    filefield/

    /members
    */node/

    Flush cache when needed

    Final problem we walked into: when you re-arrange the group menu, or changed the Features in a group: views stayed cached. So pages wouldn't show activated Features. To solve this we had to flush cache upon changing group features, or changing the menu order. This code did the trick:

    /
    * Implementation of hook_form_alter().
    *
    */
    function lucius_helpers_form_alter(&$form, &$form_state, $form_id) {
      //Clear content and page cache upon turning features on/off and moving menu items (else authcache will serve wrong page from cache)
      if ($form['#id'] == "spaces-features-form" || $form['#id'] == "spaces-get-menu-editor" ){
        $form['#submit'][] = '_lucius_helpers_clear_content_cache';
      }
    }

    /

      * Cache clearing helper function
      */
    function _lucius_helpers_clear_content_cache(){
      cache_clear_all(NULL, 'cache_content');
      cache_clear_all(NULL, 'cache_page');
    }

    Comments

    Nóg meer
    kennis nodig?

    Check ons ons blog archief >