[Dbix-class] Replication

Brandon Black blblack at gmail.com
Thu Oct 25 00:10:45 GMT 2007


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



More information about the DBIx-Class mailing list