Scaling question - separating model reads and writes across databases
Hi,
I wonder if anyone out there has done the following in a production
situation that they could provide feedback on?
/app/config/database.php:-
$read = array('host'=>'127.0.0.1');
$write = array('host'=>'1.2.3.4');
/app/app_model.php:-
beforeFind() { $this->useDbConfig = 'read'; }
beforeSave() { $this->useDbConfig = 'write'; }
beforeDelete() { $this->useDbConfig = 'write'; }
Then use database replication from the "write" host back to the "read"
host(s) thus deploying a classic master-write, multi-read database
setup.
It *seems* like this technique should work quite nicely and would
permit easy scaling but are there any CakePHP related gotchas I'm not
aware of?
Looking at the Model class source indicates the field() and read()
methods use Model->find() but if I'm not mistaken (and I could be!) I
don't believe those Model->find() calls will get passed through my
child beforeFind() callback and they could thus miss a $this-
>useDbConfig adjustment. Perhaps the answer this that is to just go
ahead and overload all find, save, delete, read, field and query
methods in AppModel and insert a $this->useDbConfig statement before
passing back to their respective parents.
Anyway, has anyone got feedback or experiance doing this with CakePHP
in this way? Did it work for you?
Cheers,
N
Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home