Welcome, Guest. Register Now!
   
Mark Forums Read Mark Forums Read Mark Forums Read


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-06-2008, 03:51 PM
Junior Member
 
Join Date: Mar 2008
Posts: 3
Lightbulb Twin Adapter

Hello everyone! This is a first time post.

We've got a database with replication set up. In this case, we want the website to be doing all its queries from the slave databases but all its additions and alterations to the master database.

It seems to me that the easiest PHP solution is to set up a twin adapter (extension of Zend_Db_Adapter_Abstract) that takes two other adapters as arguments. All the fetch and describes get passed to the 'slave' adapter and all the insert, updates and delete methods get passed to the 'master' adapter.

In fact, this seems so simple that I'm pretty sure someone's done it. Has someone created the adapter I describe? Can anyone think of a reason why this wouldn't work or a better way of doing it?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 03-06-2008, 05:24 PM
xentek's Avatar
Senior Member
 
Join Date: Feb 2008
Posts: 112
Default

You should reconsider this approach. If you wanted two seperate database servers, then do seperate servers. But if you have a master/slave, then you should utlize MySQLs replication tools and techniques to get the most out of it. The DB is going to be better at this than anything you can do on the client side (php being the client of mysql).

Replication as a scale out method is meant for apps that rarely insert/update, but do lots of reads. More info here: MySQL :: MySQL 5.0 Reference Manual :: 15.2.3 Using Replication for Scale-Out

If you do more writes than reads, or have a mixed result, consider a mysql cluster as a scale out solution: MySQL :: MySQL Cluster
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 03-06-2008, 11:16 PM
Junior Member
 
Join Date: Mar 2008
Posts: 3
Default Replication

I don't see that the documentation you've helpfully posted is inconsistent with my approach. We're going to do replication exactly as you describe, but it won't do us any good if we're always reading and writing from the master. The documentation itself says I need to change my website code (in this case, Zend Framework):

If the part of your code that is responsible for database access has been properly abstracted/modularized, converting it to run with a replicated setup should be very smooth and easy.

I'm not planning on using PHP to replicate. MySQL will replicated. I want to take the PHP code and "convert it to run with a replicated setup", which, as best I can tell, means setting it to read from slaves and write to the master, as my twin adapter idea does.

Now, if MySQL has its own load balancer that will redirect read requests to slaves and write requests to masters, then, great, I don't have to worry about PHP at all, and I'd need to rethink my approach. This documentation you've posted seems to suggest MySQL doesn't do it, since they're giving us advice on how to rewrite our website code.

Since replication is the way to go, and since replication seems to require something like my twin adapter, the question remains. Has someone already done it, or should I write it?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 11:42 PM.