An Illustrated Proof of the CAP Theorem

The CAP Theorem is a fundamental theorem in distributed systems that states any distributed system can have at most two of the following three properties.

  • Consistency
  • Availability
  • Partition tolerance

This guide will summarize Gilbert and Lynch's specification and proof of the CAP Theorem with pictures!

What is the CAP Theorem?

The CAP theorem states that a distributed system cannot simultaneously be consistent, available, and partition tolerant. Sounds simple enough, but what does it mean to be consistent? available? partition tolerant? Heck, what exactly do you even mean by a distributed system?

In this section, we'll introduce a simple distributed system and explain what it means for that system to be available, consistent, and partition tolerant. For a formal description of the system and the three properties, please refer to Gilbert and Lynch's paper.

A Distributed System

Let's consider a very simple distributed system. Our system is composed of two servers, G1G1 and G2G2. Both of these servers are keeping track of the same variable, vv, whose value is initially v0v0. G1G1 and G2G2 can communicate with each other and can also communicate with external clients. Here's what our system looks like.

A client can request to write and read from any server. When a server receives a request, it performs any computations it wants and then responds to the client. For example, here is what a write looks like.

And here is what a read looks like.

Now that we've gotten our system established, let's go over what it means for the system to be consistent, available, and partition tolerant.

Consistency

Here's how Gilbert and Lynch describe consistency.

any read operation that begins after a write operation completes must return that value, or the result of a later write operation

In a consistent system, once a client writes a value to any server and gets a response, it expects to get that value (or a fresher value) back from any server it reads from.

Here is an example of an inconsistent system.

Our client writes v1v1 to G1G1 and G1G1 acknowledges, but when it reads from G2G2, it gets stale data: v0v0.

On the other hand, here is an example of a consistent system.

In this system, G1G1 replicates its value to G2G2 before sending an acknowledgement to the client. Thus, when the client reads from G2G2, it gets the most up to date value of vv: v1v1.

Availability

Here's how Gilbert and Lynch describe availability.

every request received by a non-failing node in the system must result in a response

In an available system, if our client sends a request to a server and the server has not crashed, then the server must eventually respond to the client. The server is not allowed to ignore the client's requests.

Partition Tolerance

Here's how Gilbert and Lynch describe partitions.

the network will be allowed to lose arbitrarily many messages sent from one node to another

This means that any messages G1G1 and G2G2 send to one another can be dropped. If all the messages were being dropped, then our system would look like this.

Our system has to be able to function correctly despite arbitrary network partitions in order to be partition tolerant.

The Proof

Now that we've acquainted ourselves with the notion of consistency, availability, and partition tolerance, we can prove that a system cannot simultaneously have all three.

Assume for contradiction that there does exist a system that is consistent, available, and partition tolerant. The first thing we do is partition our system. It looks like this.

Next, we have our client request that v1v1 be written to G1G1. Since our system is available, G1G1 must respond. Since the network is partitioned, however, G1G1 cannot replicate its data to G2G2. Gilbert and Lynch call this phase of execution α1α1.

Next, we have our client issue a read request to G2G2. Again, since our system is available, G2G2 must respond. And since the network is partitioned, G2G2 cannot update its value from G1G1. It returns v0v0. Gilbert and Lynch call this phase of execution α2α2.

G2G2 returns v0v0 to our client after the client had already written v1v1 to G1G1. This is inconsistent.

We assumed a consistent, available, partition tolerant system existed, but we just showed that there exists an execution for any such system in which the system acts inconsistently. Thus, no such system exists.

Reprinted from here

An Illustrated Proof of the CAP Theorem的更多相关文章

  1. 【翻译】Brewer's CAP Theorem CAP定理

    Brewer's CAP Theorem 原文地址:http://www.julianbrowne.com/article/brewers-cap-theorem Brewer’s (CAP) The ...

  2. [转]A plain english introduction to cap theorem

    Kaushik Sathupadi Programmer. Creator. Co-Founder. Dad. See all my projects and blogs → A plain engl ...

  3. CAP theorem

    https://en.wikipedia.org/wiki/CAP_theorem

  4. CAP Confusion: Problems with ‘partition tolerance’

    by Henry Robinson, April 26, 2010 The 'CAP' theorem is a hot topic in the design of distributed data ...

  5. CAP理论中, P(partition tolerance, 分区容错性)的合理解释

    在CAP理论中, 对partition tolerance分区容错性的解释一般指的是分布式网络中部分网络不可用时, 系统依然正常对外提供服务, 而传统的系统设计中往往将这个放在最后一位. 这篇文章对这 ...

  6. 分布式系统的一致性级别划分及Zookeeper一致性级别分析

    最近在研究分布式系统的一些理论概念,例如关于分布式系统一致性的讨论,看了一些文章我有一些不解.大多数对分布式系统一致性的划分是将其分为三类:强一致性,顺序一致性以及弱一致性.强一致性(Strict C ...

  7. Tychonov Theorem

    (Remark: The proof presented in this post is a reorganization and interpretation of that given by Ja ...

  8. CAP Twelve Years Later: How the "Rules" Have Changed

    The CAP theorem asserts that any net­worked shared-data system can have only two of three desirable ...

  9. 分布式系统理论基础 - CAP

    引言 CAP是分布式系统.特别是分布式存储领域中被讨论最多的理论,“什么是CAP定理?”在Quora 分布式系统分类下排名 FAQ 的 No.1.CAP在程序员中也有较广的普及,它不仅仅是“C.A.P ...

随机推荐

  1. OpenFOAM——在钝板上分离的层流

    本算例来自<ANSYS Fluid Dynamics Verification Manual>中的VMFL063: Separated Laminar Flow Over a Blunt ...

  2. webpack4.0中文文档踩坑记录

    一直没有正儿八经去看过webpack4.0的文档,前段时间工作比较轻松,于是就有了此文...面都这样一个问题:请问在您的开发生涯中,令你最痛苦最无奈的是什么?小生的回答只有一个:“阅读那些令人发指的文 ...

  3. 禁用F12,屏蔽鼠标右击、

    $(document).ready(function(){ $(document).bind("contextmenu",function(e){ return false; }) ...

  4. Characters with Hash[签到题]

    目录 题目地址 题干 代码和解释 参考 题目地址 Characters with Hash(ACM-ICPC 2018 徐州赛区网络预赛) 题干 代码和解释 本题很好理解,通过一个seed,将输入的定 ...

  5. Mongodb聚合 时间分组(转载)

    // Requires official MongoShell 3.6+ use MediaNetDB; db.getCollection("TestCollection").ag ...

  6. JAXB xml序列化应注意

    使用JAXB将对象序列化为XML时,发现有一个地方性能非常低,即 JAXBContext.newInstance(XXX.class); 建议将其提前创建好并作为变量保存,到时可直接使用其引用,而非重 ...

  7. zz 勵志貼,成功是努力加对的方向

    5-6年工作经验程序员初进大厂,如何适应工作? 李苦李 李苦李 ​ 华为 架构师 318 人赞同了该回答 泻药! 与题主背景非常相似. 本人毕业8年+,普通二本,学历不突出,非计算机专业. 唯一不同的 ...

  8. odoo开发笔记 -- 提高访问安全性的一种方式

    场景描述: 最近在做项目的过程中,需要需要将odoo应用集成到其他系统中, 在对方的系统中点击我们的应用,打开对应系统,但是界面不做跳转,在当前页面打开,并且浏览器地址栏只显示IP+应用名,不让显示o ...

  9. 谈谈RPC——golang中jsonrpc和grpc的使用

    前言 不知从什么时候rpc这个东西开始进入我们的视野,一开始做开发的时候经常使用的都是http,偶尔使用的是socket进行通信,使用的是restful的方式.但是,一次偶然的机会你会发现RPC这个东 ...

  10. WebGL学习笔记(八):光照

    局部光照与全局光照 局部光照 只考虑光源到模型表面的照射效果,运算量较小: 全局光照 考虑到环境中所有表面和光源相互作用的照射效果,即让没有直接受光照射的位置也会受周围反射光的影响,运算量较大: Ph ...