Khanh Hoang - Kenn
Kenn is a user experience designer and front end developer who enjoys creating beautiful and usable web and mobile experiences.
Drupal is powerful CMS which used to built many high traffic websites. However, the performance of Drupal always a concern for many users. In my pervious article introduced 4 simple steps to boost Drupal performance for many anonymous visit. However, if your find those are not enoguht, there are 3 extra tricks which can further boost Drupal performance.
CacheRouter is a module which can replace default Drupal caching mechanisms which allowing you to use individual cache tables for specific cache technology.
And CacheRouter fully support the following technologies:
i ) Enable the module in admin panel
Your should go to "http://yourdomain.com/admin/build/modules" to enable the CacheRouter module
ii) Configurate settings.php
First, you have to inform Drupal to use your common caching system by adding the follow line in setting.php.
$conf['cache_inc'] = './sites/all/modules/contrib/cacherouter/cacherouter.inc'; $conf['cacherouter'] = array( 'default' => array( 'engine' => 'db', 'servers' => array(), 'shared' => TRUE, 'prefix' => '', 'path' => 'sites/default/files/filecache', 'static' => FALSE, 'fast_cache' => TRUE, ), );
The above setting which tell Drupal to user CacheRouter to user for all cache bins and store the cache content as files. The cache store in 'sites/default/files/filecache' directory.
There are several database tables that shipped with Drupal 6 for caching purpose:
Other than default cache tables, there are some common cache tables used by those widely used modules:
Now, we have a brief understand how Drupal cache the data into which database tables. Here, we can do some extra cache configuration:
$conf['cacherouter'] = array( 'default' => array( 'engine' => 'file', 'servers' => array(), 'shared' => TRUE, 'prefix' => '', 'path' => 'sites/default/files/filecache', 'static' => FALSE, 'fast_cache' => TRUE ), 'cache_menu' => array( 'engine' => 'db', 'servers' => array(), 'shared' => TRUE, 'prefix' => '', 'path' => '', 'static' => FALSE, 'fast_cache' => TRUE ) );
We can specify different cache bins use different kind of cahce mechanism. Like the code on above which specify "cache_menu" use db to cache.
Drupal's cron is an useful tool which can run heavy tasks in background through hook_cron. However, there are some limitations:
By using Elysia Cron which allow you with great flexibility to manage your cron tasks, such as: reorder cron tasks, disable cron tasks. It also give you information on which cron task consumes most of the time. For more information, visit the module page here.
To further optimize, there is one more option is to use Memcahe. It used RAM for storing data which is extremely fast. And we can configure cache bins to storu in memory. In order to do this, you should make sure your server installed with Memcached caching. Once your server installed, we can configurate Drupal use Memcache by adjusting configuration of CacheRouter.
$conf['cacherouter'] = array( 'default' => array( 'engine' => 'memcache', 'servers' => array('127.0.0.1:11211', '127.0.0.1:11212'), 'shared' => TRUE, 'prefix' => 'your_site_name_prefix', 'path' => '', 'static' => FALSE, 'fast_cache' => TRUE ) );
Here, we configurated Drupal to use memcached as backend with 2 instances ('127.0.0.1:11211', '127.0.0.1:11212'). And you can configurate the 2 instances located at two different IPs and ports, such as: '192.168.1.100:11211', '192.168.1.101:11212' . Prefix is used to separate different caches from each others. For instance - you may have several Drupal projects, which may use same memcached instances.
In most cases, you need to configurate the size of bins and instances:
default: For cache, cache_views, cache_update. 256 MBytes in size.
menu: For cache_menu bin. 64 MBytes in size.
content: For cache_views_data, cache_content, cache_page bins. 64 MBytes in size.
block: For cache_block bin. 64 MBytes in size.
filter: For cache_filter bin. 64 MBytes in size.
form: For cache_form bin. 64 MBytes in size.
CacheRouter is a very useful module which allow Drupal to work with various kinds of cahching mechanism, such as: file base, db, memcache ... etc. However, compare CacheRouter with Boost module, it require more configuration and settings. However, it do provide more flexibility to optimize Drupal performance which is a very useful module to optimize performance for high traffic web site.