The CAP Theorem states that, in a distributed system, you can only have two out of the following three guarantees across a write/read pair: Consistency, Availability, and Partition Tolerance => One of them must be sacrificed.
Consistency: A read is guaranteed to return the most recent data (the most up to date). ^414f7e
Availability: Every request will return a response (but no guarantee that the response will contain the most up to date data)
Partition Tolerance: The system will continue to function when network partitions occur( which means that there's an error during the communication between nodes in the system)
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 [[RDBMS#^89a246 | atomic]] reads and write.
AP - availability and partition tolerance
Response 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 [[Consistency patterns#Eventual Consistency | eventual consistency]] or when the system needs to continue working despite external errors