CAP theorem - Availability and Partition Tolerance

后端 未结 9 1741
囚心锁ツ
囚心锁ツ 2020-12-04 04:09

While I try to understand the \"Availability\" (A) and \"Partition tolerance\" (P) in CAP, I found it difficult to understand the explanations from various articles.

<
9条回答
  •  天命终不由人
    2020-12-04 05:09

    I have gone through lot of links, but none of them could give me satisfactory answer, except one.

    Hence I am describing CAP in very simple wordings.

    • Consistency: Must return same Data, regardless to from which node is it coming.

    • Availability: Node should respond (must be available).

    • Partition Tolerance: Cluster should respond (must be available), even if there is a a partition (i.e. network failure) between nodes.

    ( Also one main reason it confuses more is bad naming convention of it. If I had right, I might have given DNC theorem instead: Data Consistency, Node Availability, Cluster Availability, where each corresponds to Consistency, Availability and Partition Tolerance respectively )

    CP database: A CP database delivers consistency and partition tolerance at the expense of availability. When a partition occurs between any two nodes, the system has to shut down the non-consistent node (i.e., make it unavailable) until the partition is resolved.

    AP database: An AP database delivers availability and partition tolerance at the expense of consistency. When a partition occurs, all nodes remain available but those at the wrong end of a partition might return an older version of data than others. (When the partition is resolved, the AP databases typically resync the nodes to repair all inconsistencies in the system.)

    CA database: A CA database delivers consistency and availability across all nodes. It can’t do this if there is a partition between any two nodes in the system, however, and therefore can’t deliver fault tolerance. In a distributed system, partitions can’t be avoided. So, while we can discuss a CA distributed database in theory, for all practical purposes, a CA distributed database can exist but should not exist.

    Hence, this doesn’t mean you can’t have a CA database for your distributed application if you need one. Many relational databases, such as PostgreSQL, deliver consistency and availability and can be deployed to multiple nodes using replication.

    Source: https://www.ibm.com/cloud/learn/cap-theorem

提交回复
热议问题