Cache Router
About
CacheRouter is a caching system for Drupal allowing you to assign individual cache tables to specific cache technology. CacheRouter also utilizes the page_fast_cache part of Drupal in order to reduce the amount of resources needed for serving pages to anonymous users.
Most of the code comes from refactoring the following projects: APC, fastpath_fscache, Memcache, and XCache.
Note: Please be aware that this module uses page_fast_cache to avoid database hits when using any of the types besides "db" caching. You will not get information in statistics for Anonymous users if you use this module.
Installation
- Enable the module in admin/build/modules.
- Setup your settings.php
Configuration
CacheRouter has some pretty sane defaults, and it usually won't hurt to leave it in the default mode. With that said there are a few tweaks that are critical especially if you are running multiple sites.
Add the following lines to your settings.php:
$conf['cache_inc'] = './sites/all/modules/cacherouter/cacherouter.inc';
$conf['cacherouter'] = array(
'default' => array(
'engine' => 'db',
'server' => array(),
'shared' => TRUE,
'prefix' => '',
'path' => '/tmp/filecache',
),
);If you are using the 5.x branch of this module, you must apply the core "cache serialization" patch.
# cd /path/to/drupal
# patch -p0 < sites/all/modules/cacherouter/patches/DRUPAL-5-7-cache-serialize.patchdefault is for the default caching engine. All valid cache tables or "bins" can be added in addition, but you must have a default if you skip any bins.
For engine, the current available options are: apc, db, file, memcache and xcache.
server is only used in memcache and should be an array of host:port combinations. (e.g. 'server' => array('localhost:11211', 'localhost:11212'))
shared is only used on memcache as well. This allows memcache to be used with a single process and still handle flushing correctly.
prefix is for unique site names usually when running multiple sites.
path is new in beta3 for 5.x and 6.x branches. It allows you to override the default of /tmp/filecache for storing files when using the "file" caching type.
Statistics
Here are the stats I ran on my 2.4Ghz MacBook Pro with 2GB of memory. I added 2000 Nodes, wtih 8 comments each, and 1000 users. Also added 8 taxonomies with 150 terms each. This was tested running Drupal 6.1.
All tests were done with Normal page caching on, and page compression on.
These test results show Anonymous results only.
All tests were done twice to warm up the cache with the following command:
# ab -c 5 -n 1000 -H "Accept-Encoding: gzip,deflate" http://cacherouter/NO OPCODE CACHE, NO Cache Router and query_cache OFF for MySQL:
Requests per second: 108.19 [#/sec] (mean)
Time per request: 46.215 [ms] (mean)WITH APC OPCODE CACHE, NO Cache Router and query_cache OFF for MySQL:
Requests per second: 279.85 [#/sec] (mean)
Time per request: 17.867 [ms] (mean)WITH APC OPCODE CACHE, NO Cache Router and query_cache ON for MySQL:
Requests per second: 428.39 [#/sec] (mean)
Time per request: 11.672 [ms] (mean)WITH NO OPCODE CACHE, WITH Cache Router and "db" caching and query_cache OFF for MySQL:
Requests per second: 104.84 [#/sec] (mean)
Time per request: 47.692 [ms] (mean)WITH APC OPCODE CACHE, WITH Cache Router and "db" caching and query_cache OFF for MySQL:
Requests per second: 265.02 [#/sec] (mean)
Time per request: 18.866 [ms] (mean)WITH APC OPCODE CACHE, WITH Cache Router and "db" caching and query_cache ON for MySQL:
Requests per second: 405.27 [#/sec] (mean)
Time per request: 12.337 [ms] (mean)WITH APC OPCODE CACHE, WITH Cache Router and "file" caching:
Requests per second: 823.05 [#/sec] (mean)
Time per request: 6.075 [ms] (mean)WITH APC OPCODE CACHE, WITH Cache Router and "apc" caching:
Requests per second: 886.14 [#/sec] (mean)
Time per request: 5.642 [ms] (mean)WITH APC OPCODE CACHE, WITH Cache Router and "memcache" caching:
Requests per second: 921.14 [#/sec] (mean)
Time per request: 5.428 [ms] (mean)TODO
A few things I would like to have done.
- Add session support. Just like the memcache project. (I am working on this and it will be done soon.)
- Allow cache "chaining", for example, it would be nice to have default and a "backup" cache so for any critical cache (not that there should be critical caches), you could have memcache backed by db or file backed by db or memcache backed by apc backed by db. Not sure how I would like to implement this yet.
- I would love to see this tested on large production sites and work out the bugs and get it into core. I don't see why this caching shouldn't be part of Drupal core.
- Any ideas for additional caching types.
- I would love to get a really nice, clean web stats thing going with pretty pictures and everything.
Maintainer
CacheRouter is maintained by Steve Rude.
Releases
| Official releases | Date | Size | Links | Status | |
|---|---|---|---|---|---|
| 6.x-1.0-beta4 | 2008-Jun-02 | 14.6 KB | Download · Release notes | Recommended for 6.x | |
| 5.x-1.0-beta4 | 2008-Apr-07 | 15.93 KB | Download · Release notes | Recommended for 5.x | |
