Cap

CAP theorem: Consistency, Availability, Partition Tolerant.

Consistency: If master says the txn committed, then it should be immediately visible on replicas.

Availability: Achieving availability in a distributed system requires that the system remains operational 100% of the time.

Partition TOLERANCE means tolerance to a network partition. A network partition is when two nodes can't talk to each other, but there are clients able to talk to either one or both of those nodes.

  • By consistency we mean that all participating systems share the same view of the data.
  • By Availability we mean that the system is able to respond quickly enough for the user's needs.
  • By Partition tolerance we mean that, in the event of the failure or isolation of some participants, the other participants can continue to do whatever they can.
  • CA : mysql
  • CP: commuication among server to get consistence but not availability
  • PA: several servers but no consisitence

Networks aren't reliable, so you'll need to support partition tolerance. You'll need to make a software tradeoff between consistency and availability.

CP - consistency and partition tolerance Waiting for a response from the partitioned node might result in a timeout error. CP is a good choice if your business needs require atomic reads and writes.

AP - availability and partition tolerance Responses return the most readily available version of the data available on any node, which might not be the latest. Writes might take some time to propagate when the partition is resolved.

AP is a good choice if the business needs allow for eventual consistency or when the system needs to continue working despite external errors.