比例定理关系数据库在CAP定理中将落在哪里? [英] Where would a scaled relational DB fall in the CAP theorem?

查看:117
本文介绍了比例定理关系数据库在CAP定理中将落在哪里?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果您已扩展SQL Server,且其中一个DB用于写入,而多个DB用于读取.将数据从写DB复制到到其他读数据库是否会有延迟?在哪种情况下数据不是不一致的?

If you have scaled SQL server with one DB for writes and multiple DBs for reads. Wouldn't there be a delay for data to be replicated from the write DB to the to other read databases? In which case isn't the data inconsistent?

那么可缩放的关系数据库在CAP定理中将落在哪里?

So where would a scaled relational DB fall in the CAP theorem?

更新:

在关系数据库中,一致性意味着不会进行部分更新.例如,如果某人将钱从一个帐户转移到另一个帐户,而整个事情是一个交易的一部分,那么您不会从一个帐户中取出钱,而不会出现在另一个帐户中.

In relational DBs consistency means there wont be partial updates. For example if someone transfers money from one account to another and the whole thing is a part of one transaction, it wont happen that you take money out of one account but doesn't show up in another account.

在CAP定理中,一致性意味着所有组件都可以看到相同的数据.这种一致性不同于ACID中的一致性.

In CAP theorem consistence means all the components see the same data. That consistency is different from consistency in ACID.

据我所知,像SQL Server这样的关系数据库应该是CA(一致且可用).如果只有一个数据库,这将是有意义的.因为每个人都会看到相同的数据.但是,如果SQL Server具有多个数据库扩展怎么办?在那种情况下,所有数据库仍会看到相同的数据吗?如果不是,是否一致(在CAP定理中)?

From what I know, relational DBs like SQL server are supposed to be CA (consistent and available). This would make sense if there is just one database. Because everyone would see the same data. But what if the SQL server is scaled with multiple databases? In that case would all databases still see the same data? If not, would it be consistent (in CAP theorem)?

我的感觉是,关系数据库的扩展比例是AP(可用且分区容忍),而不是CA(一致且可用).

My feeling is a scaled relational DB is AP (Available and partition tolerant) and not CA (Consistent and available).

推荐答案

关于CAP定理,我已经阅读了不同的一致性定义.

I've read different definitions of consistency in regards to the CAP theorem.

  1. 一些一致性定义表明,一旦某些数据保留在系统中,所有读取将读取最近写入的数据.在此定义中,如果复制是异步的,则复制的数据库(您称其为缩放",但我不会使用该术语)有返回不一致数据的风险.

  1. Some definitions of consistency say that once some data is persisted in a system, all reads will read the most recently written data. In this definition, a replicated database (you call this "scaled" but I wouldn't use that term) has a risk of returning inconsistent data, if the replication is asynchronous.

为减轻这种风险,某些系统确保复制是同步的,或者尽可能实现同步.例如,Galera将事务写集同步发送到其副本.如果您尝试从副本中读取数据,并且它检测到有待处理但尚未应用的写集,则它可以阻止您的读取,直到它追上了待处理的写集(此行为是可配置的).因此,您永远不会读取过时的数据.

To mitigate this risk, some systems make sure replication is synchronous, or as close to synchronous as they can implement. Galera, for example, sends transaction write sets to its replicas synchronously. If you try to read from the replica, and it detects that there are write sets pending but not yet applied, it can block your read until it has caught up with the pending write sets (this behavior is configurable). So you'll never read data that is out of date.

以这种方式在分布式系统上保持完全一致的读取的成本通常比用户想要的昂贵.这将成为更新率很高的系统中的性能瓶颈.因此,出于实际原因,大多数项目都认为复制滞后"是必要的折衷办法.

The cost of maintaining perfectly consistent reads over distributed systems in this manner is usually more expensive than users want. It will become a performance bottleneck in a system that has a high rate of updates. So for practical reasons, most projects accept that "replication lag" is a necessary compromise.

一致性的其他定义更接近 atomicity ,即交易将不会以部分完成的状态持续存在.因此,无论您在应用事务之前还是之后读取数据,在读取数据时都将满足所有约束.在此定义中,如果复制数据库实例使用主服务器上使用的相同事务语义应用更新,则很容易想象副本数据库实例保持一致.如果您从副本中读取数据,则可能会读取尚未应用最新更新的数据,但是就约束而言,它永远不会处于不一致的状态.

Other definitions of consistency are closer to atomicity, i.e. transactions will not be persisted in a partially-complete state. So all constraints will be satisfied when you read the data, whether you read the data before or after the transaction is applied. In this definition, it's quite easy to imagine the replica database instance remaining consistent, if it applies updates using the same transaction semantics used on the master. If you read data from the replica, you might read data that hasn't yet had the latest updates applied, but it will never be in an inconsistent state with respect to constraints.

这篇关于比例定理关系数据库在CAP定理中将落在哪里?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆