What does “absence of any further writes” mean in documentDb eventual consistency model?

偶尔善良 提交于 2019-12-11 07:28:06

问题


The documentDb documentation (at https://docs.microsoft.com/en-us/azure/documentdb/documentdb-consistency-levels) has following information in it:

Eventual: Eventual consistency guarantees that in absence of any further writes, the replicas within the group will eventually converge.

What does absence of any further writes mean?

Lets say that I represent my write operation as W(x, s1, t1) where x is the record/document, updating it to state 1 at time 1. Here are my sequence of write events:

W(A, s1, t1), W(B, s1, t1), W(B, s2, t2), W(C, s1, t3) where t1 < t2 < t3 with t3-t1 = 100 milliseconds (say).

1) Do propagation of changes to other replicas for each record A, B, C begin independently? If so, is there a wait period involved for each record to detect stream of updates for a given record?

2) Do propagation of changes to other replicas for each record A, B, C only begin after some time (tn) after t3 (which signals the end of writes)?

3) Assuming that I have only W(A, s1, t1) and don't write any more events for any records, typically how long it will take to propagate record A changes to all replicas? (AWS Dynamodb claims this to be under a second; I did not find any such claim for documentDb)


回答1:


Replication in DocumentDB has no intrinsic delays built into it. Within single region configurations, you have at most a few milliseconds lag between replicas in practice. In multi-region setups, it's about the network ("speed of light") lag between regions plus some compute overhead.

The reason the docs say "some time" is because this lag is dependent on your topology, and network partitions. In cases of network partitions, eventual consistency favors availability over consistency (staleness), so a replica can fall behind.

DocumentDB's implementation of eventual consistency guarantees a very high probability of consistent reads (See http://pbs.cs.berkeley.edu/). If you want stronger guarantees, you can choose a consistency level like Session, BoundedStaleness or Strong.




回答2:


The idea is that, when you write some data, there is some time delay until all replicas have that same operation applied to them.

So, for any given point in time that you write data, there could be one or more replicas slightly out of sync.

When the documentation mentions "absence of any further writes," it's just saying that, if you finished writing a set of documents, and wrote nothing else for a while, eventually all of the replicas would be in the exact same state. Each replica eventually being consistent with each other. Conversely: if you kept on writing, and never stopped writing, then your individual replicas would likely always be slightly out of sync with the master you just wrote to (with regard to the latest documents you just wrote).

TL;DR the documentation is just trying to show how data ends up being consistent after a write.



来源:https://stackoverflow.com/questions/43551520/what-does-absence-of-any-further-writes-mean-in-documentdb-eventual-consistenc

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!