Welcome Guest, Not a member yet? Register   Sign In
Multiple Database connection - Core Hack
#1

[eluser]majidmx[/eluser]
Hi guys,

We are migrating from a single server to a load-balanced setup having 2 DB servers.
One is Master read/write and one is slave Read. So all the UPDATE/INSERTs go to Master and then replicated to slave, and all the SELECT go to slave [other than some performance critical modules which both go to Master].

I want to get you opinion on some issues :
The best way is to modify all the existing models to have two DB connections and using

Code:
$DBr->query();
$DBw->query();

But what do you think if we can hack the core and change the
Code:
function query($sql, $binds = FALSE, $return_object = TRUE)
{...}
in system/Database/DB_Driver.php to check each coming query for keywords of INSERT / UPDATE then change the DB connection to DB1, and for SELECT change the DB connection to DB2 ?

Let me know what you think about it.

Also as a less important issue, what do you think aout using persistent connections for both DBs. I know there are some issue with Apache threads and mysql persistent connections, and it's not recommended to multiple persistent connections to different DBs on the same machine, but what if they're on different machines ?

I really appreciate your advices.

Thanks,
MajiD
#2

[eluser]majidmx[/eluser]
Could it be an adapter in between to take care of this ?

What you guys think ?

Thanks,




Theme © iAndrew 2016 - Forum software by © MyBB