淺談 分布式中的 Consistency

擷取自網路

Consistency in distributed system …

在分布式中,我們一直談論一致性的問題。也為了一致性想出了多種的架構及分法。那麼我們所追求的一致性,到底可以分幾種呢。

In distributed system, we usually mention about consistency. For it, we figured out many approaches and architectures. How many types of consistency we are desired?

Linearizability …

  1. 每個寫入順序完全一樣。 Total ordering of writes.
  2. 讀取時,返回最後完成結果。 When read data, it always returns last completed result.
  3. 一致性最高,但是花費的效能也最高。 The strongest consistency, but the cost of efficiency is highest.

Sequential consistency …

  1. 所以執行序看到的執行結果相同。 The result shows in any process is the same.
  2. 讀取時,不保證回傳最終的完成結果。 There is no guarantee that it returns last completed result when read data.

Example 1
這時候,所有的執行序看到一樣的結果,這是 sequential consistency 的情況。
In this time, all processes see the same result. It is sequential consistency.

Example 2
這次的結果,執行序 3 跟 執行序 4 看到不一樣的結果,沒有達成 sequential consistency。
This time, process 3 and process 4 see different result. It is not sequential consistency.

Causal consistency …

  1. 結果顯示順序是按照因果排序。The results order by causally.
  2. 如果動作 a 比動作 b 執行更早,則看到 b 時,一定會看到 a。If the action a happened before action b, then users would see action a if they see action b.

Example 1
如果你看到一則評論,一定會看到評論的文章。
If you see a comment, you must see the post which the comment is commented.

Example 2
執行序 4 符合 causal consistency,但不符合 sequential consistency。
Process 4 is causal consistency, but it is not sequential consistency.

-MsHe

發表留言