C - Consistency A - Availability
Single Node Architecture
Single node architecture models are inefficient as they cause a single point of failure, hence there is the use of distributed replicas (ref: Distributed Consensus DB)
Multiple Nodes System
Storing data in multiple nodes makes it more reliable, but data can be inconsistent.
Suppose, we want to lock operations until it becomes consistent, then it can be unavailable for that time.
Hence Consistency is inversely proportional to Availability
This is the Consistency Trade off
Then there's Master - Slave Distributed System, as seen in Distributed Consensus DB
2- Phase commit
Similar to the TCP-IP protocol
To ensure consistency on saves, we use a 2-way ACK,
- First a "prepare" req is send from master -> slave
- If failure at any point -> rollback the system
- Once prepare is done, ask to commit, after commit -> master updates itself as it knows it is consistent to save data now.