CAP is a set of principles that a distributed system which storse state can fallow.
It is said that such a system can only choose 2 out of the 3 though some argue that this is only partially true.
- Consistency: Every node in the system returns the most recent successful write
- Availability: Every node returns a response
- Partition Tolerance: System continues to work even if there is a break between nodes (i.e. one node goes down or the connection to that node goes down)
One must choose either CP or AP. Partitions, i.e. network failures are unavoidable, and thus must always be included. While a single node in the system may choose CA the entire system as a whole cannot.
Here is an example of choosing CP. For every node in the system to return the most recent response (C), that response must have already propagated to every node in the system. If a client attempts to make a request to a node for which the request has not yet propagated to, then in the CP combination, the system will temporarily become unavailable in order to finish propagating the response.
Base is a set of principals similar to ACID. BASE is looser and less restrictive than ACID and is used by NoSQL databases.
- Basically Available: Sometimes down. Good enough
- Soft State: State may change, even without an input. This is primarily due to the next principal
- Eventually Consistent: System will eventually be consistent. For example, when it stops receiving input, it can propagate that new input to the other nodes