Needs work
Project:
Cache Router
Version:
6.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
18 Mar 2010 at 22:42 UTC
Updated:
28 Apr 2010 at 08:31 UTC
I'd like to see the CacheRouter module be able to support a backup cache engine, similar to how the memcache module allows you to use an alternate include that defaults over to a database cache. I've attached a patch that allows an optional 'engine_backup' $conf parameter to specify a backup if desired. Ex.
$conf['cacherouter'] = array(
'default' => array(
'engine' => 'apc',
'engine_backup' => 'db',
'server' => array(''),
'shared' => TRUE,
'prefix' => '',
'path' => '',
'static' => FALSE,
'fast_cache' => FALSE,
),
);
When the result of any of the CacheRouter class functions is false, the class will now check the backup engine as well, if configured. This could prevent very large sites from going down from uncached database queries if their initial cache engine was unresponsive.
| Comment | File | Size | Author |
|---|---|---|---|
| engine_backup.patch | 5.77 KB | ebrueggeman |
Comments
Comment #1
andypostInteresting idea, looks fine! So let's gather reviews from community and I glad to see this in upcoming release.
Comment #2
ebrueggeman commentedChanging to correct Cache Router version (6.x-1.x-dev)
Comment #3
cweagansIt seems like if you are going to implement a caching scheme like this, you might want to consider making the number of caching layers arbitrary. For example:
Comment #4
andypost@cweagans no it's different, priority has no meaning because 'backup1' and 'backup2' is cache tables not an abstract bins.
Comment #5
ebrueggeman commentedYea, I agree with @andypost - an arbitrary number of bins has limited use to me. I think the backup cache bin is for a very specific, but possible scenario of failure with the initial bin, which is often an in-memory, fixed size bin.
Comment #6
Carl Johan commentedI don't know if you've seen the old issue http://drupal.org/node/365088 where something like this was discussed (and dropped?) earlier, seems like there are some old thoughts/concerns in there.
Anyway, I'd love to see this in CacheRouter; we've been running a similar system that would
- Try to fetch from cacherouter (apc)
- Success?
-- Yes: Return value
-- No: Try to fetch from cacherouter (database)
-- Success?
--- Yes: Store in APC, return value
--- No: Generate value, store in database & apc
The last step (generation) we're trying to handle as much as possible in cron jobs; but for some cases that hasn't been possible.
There's also a similar discussion at http://fourkitchens.com/blog/2009/11/30/intelligent-memcached-apc-intera...
My first concern with putting this in-cacherouter is the format of the configuration; in your example the only thing changing would be the engine type - i don't know if that would be enough for all cases? What about using a nested approach? I'd like to see cacherouter doing what David's suggesting on the four kitchens blog:
Comment #7
crea commentedThis is very poorly implemented but initially good idea. In this patch, how do you distingush between "there is no cached value for this key" vs "this cache engine failed" ? You seem to be accessing both active cache engine and backup on FALSE - which is every "not found" key too. Note that you generally *don't want to* cache every value multiple times, especially when your backup engine is much slower cause added latencies may totally kill the point of having cache. Memcache API module DB-caching mode is a very poor idea imo, we should not repeat that error.
We need a backup in a case when a caching engine failed completely. I.e.: starting with empty backup cache - good (penalizing ourselves during crash recovery until backup cache is full again), pushing every cache entry multiple times - not good (penalizing ourselves all time).
Summary:
1) Implement a new way (new method ?) for cache engine to report it failed state.
2) Make some logging in CacheRouter to report that cache engine is broken. Logging into watchdog is ok, as long as you only log it *exactly once* when failed engine was initially discovered (to not flood logs with same messages).
Also I think there's no need to define any additional array keys (e.g. 'engine_backup') cause we already have "default" cache engine which should be enough as fallback. Overcomplicating this into making several backups is unneeded IMO.UPDATE: On a second thought, engine_backup property (or similar) seems reasonable, for example in a case one has single "default" engine for all tables but still wants to have a backup for it.
Comment #8
crea commentedWe could also "mark" cache engine as failed and check it's status periodically. On success we could then return to it's usage and I think we could do it smoothly: for some time write to main engine, read both from main and backup engines. Then over time cache migrates to the main engine again and we stop using backup completely until next failure
Comment #9
andypostThere's some troubles with storage on early page cache with logging and storing variables because database unavailabality
Comment #10
andypostMarked as duplicate #779602: check for apc/engine existence
It's a good proposal but it goes to hard when we need to check version of backend. For example bug caused by old version of APC which does not support apc_add() (some redhat products affected)
To summarize:
1) Need to implement a check backend availability, also check version of php module (some kind of hook_requirements)
2) Need to implement a configuration directive to setup backup engine
3) Put 1 and 2 into base class
Comment #11
miro_dietikerso subscribing here. didn't recognize this title to be of similar topic. sure it is. :-)