[Dbix-class] Replication

Frank Speiser frank at takkle.com
Thu Oct 25 00:22:09 GMT 2007


Brandon Black wrote:
> On 10/24/07, Frank Speiser <frank at takkle.com> wrote:
>   
>> Let's say I have master DB server A and slave DB server B.
>> Say that I want to write to A and read from B.
>>
>> ...But...
>>
>> Sometimes replication lags, and I can't expect the data I want to be there on B. Now, part of this could be solved in the app... but let's say I want to read from B, unless it is a table that needs to keep track of something time-sensitive (stock trades or something).
>>
>> How would I go about directing slow reads to one server, writes to the master and fast-reads to the master as well?
>>
>> Is there something in DBIC that can work like this, or do we have to go one level up to the app to solve it?
>>
>>     
>
> Related, but not exactly an answer... it would be nice if the future
> work on DBIC's multiplexed storage also played nicely with the future
> work on DBIC's generic caching mechanisms.  We had talked a while back
> about having a generic caching thing that one could plug anything from
> Tie::Cache::LRU to Cache::FastMmap to Memcached into.  In this way,
> with memcached plugged in, you could have all writes going to the
> master and all reads coming from the slave, and never get out of date
> data (because you did the write through memcached, it's already in ram
> for reading).
>
> Of course the memcached idea breaks down unless you control all the
> code touching your database, and all of it updates via memcached.  It
> also doesn't really work out for some geographically distributed
> problems.
>
> -- Brandon

This would be good to have handy, though. Something in the base class to 
tell us to use memcache / <your caching solution here>.
If I read you correctly, you're saying overwrite the cache on updates, 
purge on delete sand insert on creates. That'd work nicely, and you'd 
have to scale pretty wide for that NOT to work.

As far as geographically distributed DB caching, I have the Net::Cloud 
namespace on CPAN and eventually I'd like to develop a plugin that'll 
allow an ORM like the one we've got here to plug into a pool of virtual 
machines like EC2 with a hook into the available pool of machines. We 
could probably even cache the YAML file which dictates what's available 
to shoot at.

With all this free time I've got laying around, I'd be up to work on it 
with someone if there's any volunteers.

-Frank



More information about the DBIx-Class mailing list