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.
很多人说通过创建只读和只写数据库可以实现更高的性能,坦白说,我无法完全理解它。有些人告诉我写作需要很多不同的锁,这会减慢阅读速度......但正如我的理解,系统中的许多读取都不需要锁定,例如oracle一致性读取,锁定如何影响读取?除了我想要分片数据库,读/写分离是否提供更多价值?您能否详细解释或提供一些外部资源,说明为什么读/写分离可以提供更高的性能,谢谢。
1 个解决方案
#1
6
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.
在应用程序中从一开始就分离读取和写入,使您可以随时灵活地进入主从路由,并且不是很难做到。当不需要这样的功能时,您可以简单地让数据库抽象使用相同的连接。
#1
6
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.
在应用程序中从一开始就分离读取和写入,使您可以随时灵活地进入主从路由,并且不是很难做到。当不需要这样的功能时,您可以简单地让数据库抽象使用相同的连接。