Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Separation Into Read/Write Only Databases

Tags:

database

Many people said that one can achieve higher performance by creating read-only and write-only database, be frankly, I can't fully understand it. Some people told me that writing will require many different locks, which will slow down the reading...but as my understanding, many reading in a system doesn't require locks, such as oracle consistent read, how do the locks affect reading? Besides if i want to shard database, does read/writing separation offer more value?
Can you give a detailed explanation or provide some external resource about why read/write separation can offer higher performance, thanks.

like image 717
Ramon Avatar asked Jan 17 '26 22:01

Ramon


1 Answers

For one, separating reads and writes allows your database to scale using master-slave replication.

In master-slave replication, the master can handle both reads and writes while the slaves handle only reads. The slave then replicates any write statements done on the master.

This allows read-heavy applications to spread reads across multiple machines. However, if your application does lots of writes and not many reads, you may see no benefit.

Separating reads and writes from the outset in your application gives you the flexibility to go the master-slave route at any time, and isn't very hard to do. You can simply have your database abstraction use the same connection for both when such functionality isn't necessary.

like image 69
Hans Avatar answered Jan 19 '26 18:01

Hans