views:

139

answers:

2

Hi!

I just finished a database layer based on redis that offers to select between multiple databases, but I have no experience by myself on what should be common sense to do. Reliability is my biggest focus.

How is writes and reads commonly organised in applications where both a slave and a master database is available?

How do the big guys pull it off?

+2  A: 

For single master, multi-slave it's often as simple as sending all data modification queries to the master and all selects to the slave. Typically your database abstraction layer can easily handle this for you. This article has some details on this particular kind of setup.

Matt S
+1  A: 

Rule 1: Don't.

Rule 2: Don't until you've measured and proven that the database really is your bottleneck. Most web application bottlenecks are the time required to serve static content and stale content. Nothing to do with database transactions.

Rule 3: Even then, look at other ways of partitioning your data rather than duplicating your database. Get history away from current data into a warehouse. Split data by customer or subject areas or web application into multiple peer databases with limited or no sharing.

Rule 4: When you can prove that there is no alternative, look at master-slave databases.

That's how many folks tackle this problem.

S.Lott