CAP Theorem

Read more about this here.

The CAP Theorem looks like this:

CAP Theorem Diagram

Partition

  • Failing to achieve consistency with a set time causes a partition
  • You can sacrifice availability to ensure consistency
  • Partitions are rare and if you have one server, almost never happen.
  • Partitions are caused by networks, failed nodes, etc…
  • Important to note, Partitions happen on Failure
  • So if you have a partition, you must choose between availability and consistency.
    • Availability: You choose not to answer requests until the partition goes away.
    • Consistency: You give the wrong answer until it goes away.

Availability

Your webpage is most likely pulling in data from a database, so availability is important.

  • Studies have shown that as little as 100ms can change the chances of a user purchasing from a web store.
  • Availability is not just unavailable, but slow returns of data.

Consistency

  • In ACID, The Database will be consistent after a transaction. All rules such as unique will be obeyed.
  • In CAP, Consistency is across partitions. Will all the partitions give the same answer?

However, it is good to remember that not everything is black and white. Although the CAP Theorem states that only two of these three properties can be had, there are tradeoffs that can be made as well. Have a read at this article for more information.