[Dbix-class] Replication

Frank Speiser frank at takkle.com
Wed Oct 24 20:23:07 GMT 2007



Brandon Black wrote:
> On 10/24/07, Jim Spath <jspath at pangeamedia.com> wrote:

> There must be DBIx::Class users who are setup and running a replicated
> database.  What solutions have you come up with?
>
>   
>
> I'm not sure what the state of the explicit support is (like
> DBD::Multi/DBD::MultiPlex).  I'm assuming what you want to do is send
> reads to the slave and writes to the master?  If so, something of this
> nature will be required.
>
> Of course, if you don't need to send reads to the slave for
> performance reasons, you can just send everything to the master, and
> use the slave separately as your backup / data warehouse.  Some people
> do failover between the two as well, with the slave being promoted to
> master on master failure.  By adding a virtual floating IP (via
> "heartbeat" in the case of linux) you can again solve that problem
> with a single normal connection from DBIC.  It's only the
> read-balancing (or even write-balancing in the case of multi-master)
> that needs some special support in DBIC.
>   
This is an interesting problem, though. We sort of hacked a fix together in CDBI that worked, but what about this scenario:

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? 




More information about the DBIx-Class mailing list