CAP Theorem

Introduction

CAP Theorem

In database theory, the CAP theorem, also named Brewer’s theorem after computer scientist Eric Brewer, states that any distributed data store can provide only two of the following three guarantees.

Consistency

  • Every read receives most recent write or an ERROR.
  • This consistency is different than C (correctness or consistency) present in ACID properties of DBMS
    • Requirement that any given database transaction must change affected data only in allowed ways.
    • Any data written to the database must be valid according to all defined rules, including constraintscascadestriggers, and any combination thereof.

Availability

  • Every request should get a response from working node without an error.
  • This means system will response and will not guarantee that read is from most recent write i.e. data can be stale / older written data.
  • If system needs to give guarantee of data consistency across distributed system then downtime will be needed and this will result in giving up on Availability property.

Partition Tolerance

  • System continues to operate despite an arbitrary number of messages being dropped or delayed in network between nodes.

What to do when network partition failure occurs ?

When a network partition failure happens, it must be decided to do one of the following.

Option A : Choose Consistency

  • Cancel the operation, thus decreasing availability but ensure consistency.

Option B : Choose Availability

  • Proceed with an operation, provide availability but RISK CONSISTENCY .
  • Note this doesn’t necessarily mean that system is highly available to its users.
  • Thus, if there is a network partition, one has to choose between consistency OR availability.

Leave a Reply

Your email address will not be published. Required fields are marked *