CAP Theorem

  • Stands for Consistency, Availability and Partition Tolerance
    • Consistency - Every read receives the most recent write or an error
    • Availability - Every request receives a response, without guarantee that it contains the most recent version of the information
    • Partition Tolerance - The system continues to operate despite arbitrary partitioning due to network failures
  • Note: Networks aren’t reliable, so you’ll need to support partition tolerance. You’ll need to make a software tradeoff between consistency and availability.
  • You either go for CP or AP pattern

Consistency Patterns


Weak Consistency

  • After a write, reads may or may not see it.
  • Used in:
    • memcached
    • Real time use cases such as VoIP, Video Chat, Realtime Multiplayer game

Eventual Consistency

  • After a write, reads will eventually see it (typically within milliseconds). Data is replicated asynchronously.
  • Used in:
    • DNS
    • Email

Strong Consistency

  • After a write, reads will see it. Data is replicated synchronously.
  • Used in:
    • File Systems
    • RDBMS

Availability Patterns


Failover

  • Active-Passive Failover
  • Active-Active Failover

Replication

  • Master-Slave Replication
  • Master-Master Replication